topical media & game development

talk show tell print

professional-search-07-seophp-include-url-utils.inc.php / php



  <?php
  
  // transforms a query string into an associative array
  function parse_query_string(query_string)
  {
    // split the query string into individual name-value pairs
    items = explode('&', query_string);
  
    // initialize the return array
    qs_array = array();
  
    // create the array
    foreach(items as i)
    {
      // split the name-value pair and save the elements to qs_array
      pair = explode('=', i);
      qs_array[urldecode(pair[0])] = urldecode(pair[1]); 
    }
  
    // return the array
    return qs_array;
  }
  
  function remove_query_param(url, param)
  {
    // remove param 
    new_url = preg_replace("#aff_id=?(.*?(&|))?#", '', url); 
  
    // remove ending ? or &, in case it exists
    if (substr(new_url, -1) == '?' || substr(new_url, -1) == '&') 
    { 
      new_url = substr(new_url, 0, strlen(new_url) - 1);
    } 
  
    // return the new URL
    return new_url;
  }
  
  ?>
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.