Let's say I have the following URL:
If I display the $_GET
array, the results looks like this:
Array
(
[size] => 60
)
How can I look the $_GET
array like this:
Array
(
[size] => 40
[size] => 60
)
Let's say I have the following URL:
If I display the $_GET
array, the results looks like this:
Array
(
[size] => 60
)
How can I look the $_GET
array like this:
Array
(
[size] => 40
[size] => 60
)
Use this, the brackets, to put it in an array.
http://www.site.com/index.php?size[]=40&size[]=60
You cannot have same keys for the $_GET
superglobal array as well as any normal arrays.
Change the name of the parameters to different ones say size1
and size2
.
Maybe you want something like this:
URL:
http://www.site.com/index.php?size[]=40&size[]=60
PHP:
foreach( $_GET["size"] as $size ){
// Here manipulate each size
}
Of course if you want to use it all this for filters, try this:
http://www.site.com/index.php?size=40,60
and in php:
foreach( explode(',',$_GET["size"]) as $size ){
// Here manipulate each size
}