0

I am trying to get values using $_GET from URL. I've used this method to extract variable values when variable names are different. But now in this case variable names are same.

http://example.com/filter.php?tags=name1&tags=name2&tags=name3

Hanky Panky
  • 46,730
  • 8
  • 72
  • 95
Ashik Basheer
  • 1,531
  • 3
  • 16
  • 36
  • 2
    Can you alter the request? If you do `tags[]=name1&tags[]=name2&tags[]=name3`, PHP will make an array for you. – lonesomeday Nov 21 '13 at 08:50
  • Lots of dupes to be found. Please use the search functionality. – PeeHaa Nov 21 '13 at 08:54
  • http://stackoverflow.com/questions/3980228/multiple-http-get-parameters-with-the-same-identifier?lq=1 http://stackoverflow.com/questions/10026198/passed-arrays-lose-all-but-first-element?lq=1 http://stackoverflow.com/questions/10678918/can-i-have-multiple-get-with-the-same-key-different-values?lq=1 http://stackoverflow.com/questions/14734750/how-to-get-multiple-parameters-with-same-name-from-a-url-in-pylons?lq=1 http://stackoverflow.com/questions/14576597/how-does-google-handle-two-same-url-parameters-with-different-values?lq=1 – PeeHaa Nov 21 '13 at 08:55

1 Answers1

-1

You could get the complete get variable with $_GET then you have an array that you can browse with

foreach ($_GET as $key => $value) echo "Key: $key Val: $value";

But I don't think to have multiple values with the same name is a good choice. You should better change the way you send your params if it's possible.

ylerjen
  • 4,109
  • 2
  • 25
  • 43