Reputation: 51
I have a URL like this
?custom[weight]=1&custom[weight2]=2
If i use echo $_GET[custom[weight]]
then it doesn't work. How do i retrive this value?
Upvotes: 0
Views: 44
Reputation: 28529
You should access it with $_GET['custom']['weight']
and $_GET['custom']['weight2']
You can check it with print_r($_GET)
and you'll get something like,
Array
(
[custom] => Array
(
[weight] => 1
[weight2] => 2
)
)
Upvotes: 1
Reputation: 5224
In the provided example $_GET
becomes multidimensional and custom
is an index with the array so you want.
foreach( $_GET['custom'] as $index => $value) {
echo $index . ' has the value of ' . $value . PHP_EOL;
}
Upvotes: 1