Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
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?
$_GET[custom[weight]]
$_GET['custom']['weight']
1
$_GET['custom']['weight2']
2
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,
print_r($_GET)
Array ( [custom] => Array ( [weight] => 1 [weight2] => 2 ) )
Add a comment
In the provided example $_GET becomes multidimensional and custom is an index with the array so you want.
$_GET
custom
foreach( $_GET['custom'] as $index => $value) { echo $index . ' has the value of ' . $value . PHP_EOL; }
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
$_GET['custom']['weight']this returns1Or$_GET['custom']['weight2']will return2