0

I have this url

http://localhost/url/stack.php?first=10&getthis=list&result=seats_booked[]=B2&seats_booked[]=B5&seats_booked[]=A20

$url = "first=10&getthis=list&result=seats_booked[]=B2&seats_booked[]=B5&seats_booked[]=A20";

parse_str($url);
echo  $seats_booked[0];

I want to get the values of array seat_booked[]. I am trying this echo $seats_booked[0]; but it is returning an error.

How can achieve this? Thanks in advance.

5
  • your code works fine, make sure you are not making any typos, enable error reporting. Commented Mar 22, 2016 at 15:20
  • simply you cannot pass an array like this in GET query, better use POST instead. If you insist to use GET anyway, check this article: stackoverflow.com/questions/7206978/… Commented Mar 22, 2016 at 15:22
  • @AlexAndrei it is not working, please note this are two different urls first=10&getthis=list&result=seats_booked[]=B2&seats_booked[]=B5&seats_booked[]=A20 and this one first=10&getthis=list&seats_booked[]=B2&seats_booked[]=B5&seats_booked[]=A20 Commented Mar 22, 2016 at 15:27
  • what error do you get? Commented Mar 22, 2016 at 15:34
  • Undefined variable: seats_booked Commented Mar 22, 2016 at 15:43

0

Your Answer

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.

Ask question

Explore related questions

See similar questions with these tags.