0

below is get request passed in my url i want value of min[min] and else likewise

min[min]=0&min[max]=50

i wrote below code which seems not working

echo $_GET['min[min]']
echo $_GET['min["min"]']

is there any specific way to get o/p

2
  • 1
    why not min=0&max=50 Oct 18, 2016 at 10:59
  • It's a multi-dimensional array: $_GET['min']['min'].
    – jeroen
    Oct 18, 2016 at 11:00

3 Answers 3

6

PHP will parse this for you (using urldecode) and put the values into an array.

You can access the values like this:

echo $_GET['min']['min'];
echo $_GET['min']['max'];

Note If you must have the square brackets (you probably shouldn't), you can url encode them, giving the query string as min%5Bmin%5D=0&min%5Bmax%5D=50, and then you can access them like this:

echo $_GET['min[min]'];
echo $_GET['min[max]'];
1

min and max will be arrays. Try this:

echo $_GET['min']['min'];
1
echo $_GET['min']['min'];
echo $_GET['min']['max'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.