Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Take all $_GET and add to end of url?

Tags:

php

I have a bunch of methods of sorting date=desc,etc,etc and they are posted via a $_GET I want to take all the $_GET variables ($_GET['anythingatall']) and transform them from $_GET['variable]=blah to &variable=blah

Is there a simple way to do this?

like image 323
Steven Avatar asked Dec 01 '22 09:12

Steven


2 Answers

You are interested in $_SERVER['QUERY_STRING'], I think. This will contain everything passed in $_GET but in the format you desire.

like image 191
mfonda Avatar answered Dec 06 '22 14:12

mfonda


This might work for you

 $string = http_build_query($_GET, null, '&')

Alex's solution should work too, and admittedly cleaner. If you wanted to create a query string from any other array using http_build_query should work fine.

like image 29
Jeff Busby Avatar answered Dec 06 '22 14:12

Jeff Busby