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.

Muya
  • 142
  • 1
  • 15
  • your code works fine, make sure you are not making any typos, enable error reporting. – Alex Andrei Mar 22 '16 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: http://stackoverflow.com/questions/7206978/how-to-pass-an-array-via-get-in-php – mitkosoft Mar 22 '16 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` – Muya Mar 22 '16 at 15:27
  • what error do you get? – Alex Andrei Mar 22 '16 at 15:34
  • `Undefined variable: seats_booked` – Muya Mar 22 '16 at 15:43

0 Answers0