I have a bunch of date = desc sorting methods, etc. etc., and they are sent via $_GET . I want to take all the $_GET variables ( $_GET['anythingatall'] ) and convert them from $_GET['variable]=blah to &variable=blah
$_GET
$_GET['anythingatall']
$_GET['variable]=blah
&variable=blah
Is there an easy way to do this?
You are interested in $_SERVER['QUERY_STRING'] , I think. This will contain everything that passed in $_GET , but in the desired format.
$_SERVER['QUERY_STRING']
This may work for you.
$string = http_build_query($_GET, null, '&')
Alex's solution should work too, and admittedly a cleaner one. If you want to create a query string from any other array using http_build_query, you should work fine.
If all you have to do is transfer the existing query string (which is available in $_GET ), you can use $_SERVER['QUERY_STRING'] , which will be exactly what you are looking for, the query string representation of the $_GET array (if you did not change it)
See the PHP documentation at the $_SERVER Supergalon .
$_SERVER
you can take a look at http://us.php.net/manual/en/function.http-build-query.php
Source: https://habr.com/ru/post/1334409/More articles:https://translate.googleusercontent.com/translate_c?depth=1&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1334404/how-to-control-where-wicket-adds-items-to-header&usg=ALkJrhjkS6fadlErj31PIqFAdWya9MUffwCan a user discard a value in a counter? - androidpluralize and divide into Spanish - ruby-on-railsHow can I align the left edge of HTML form elements with CSS? - htmlCheck "proxy"; good TDD or code smell? - unit-testingProblem with member function overload or template specialization problem - c ++Freemarker Hashtable , Key Iteration - hashtableDefine a specific case for a template function (C ++) - c ++You can watch all the intentions / broadcasts on the phone - androidIs it possible to set priority for the main thread? - javaAll Articles