Create Query String


/ Published in: PHP
Save to your folder(s)

More of a setQueryString


Copy this code and paste it in your HTML
  1. function getQueryString(Array $newQuery, $keepOld) {
  2. static $currentQueryArray;
  3.  
  4. // check to see if the current
  5. if(!is_array($currentQueryArray)) {
  6. $currentQueryArray = array();
  7. parse_str($_SERVER['QUERY_STRING'], $currentQueryArray);
  8. }
  9.  
  10. if($keepOld) $newQueryArray = array_merge($currentQueryArray, $newQuery);
  11. else $newQueryArray = $newQuery;
  12.  
  13. return http_build_query($newQueryArray);
  14. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.