How can an array be defined as a parameter in a GET request to avoid overwriting values in PHP?

When passing an array as a parameter in a GET request in PHP, you can use square brackets in the parameter name to indicate that it should be treated as an array. This way, you can avoid overwriting values and ensure that all elements of the array are properly passed and processed.

// Example of defining an array as a parameter in a GET request
// URL: example.com/index.php?colors[]=red&colors[]=blue&colors[]=green

$colors = $_GET['colors']; // $colors will be an array containing ['red', 'blue', 'green']