Posted By

andyhartleeds on 03/10/10


Tagged

get php String query


Versions (?)

Fetch $_GET array as a string representation


 / Published in: PHP
 

  1. <?php
  2. /**
  3.  * Fetches back a string representation of the current $_GET array.
  4.  *
  5.  * @version 1.0
  6.  * @author Andrew Hart
  7.  *
  8.  * @param array $exclusions[optional] Which items of the $_GET array to skip.
  9.  * @return string The $_GET array in string format, eg: "action=add&value=test&this=true"
  10.  */
  11. function fetch_query_string($exclusions = array())
  12. {
  13. $str = "";
  14.  
  15. foreach ($_GET as $key => $val)
  16. {
  17. if (!in_array($key, $exclusions))
  18. {
  19. $str .= $key . "=" . $val . "&";
  20. }
  21. }
  22.  
  23. $str = substr($str, 0, strlen($str) - 1);
  24.  
  25. return $str;
  26. }
  27. ?>

Report this snippet  

You need to login to post a comment.