PHP:
  1. // Function to parse a url and extract its arguments.
  2. function process_url( $url )
  3. {
  4. $processed_url = parse_url( $url );
  5.  
  6. $query_string = $processed_url[ 'query' ];
  7.  
  8. # split into arguments and values
  9. $query_string = explode( '&', $query_string );
  10.  
  11. $args = array( ); // return array
  12.  
  13. foreach( $query_string as $chunk )
  14. {
  15. $chunk = explode( '=', $chunk );
  16. // it's only really worth keeping if the parameter
  17. // has an argument.
  18. if ( count( $chunk ) == 2 )
  19. {
  20. list( $key, $val ) = $chunk;
  21. $args[ $key ] = urldecode( $val );
  22. }
  23. }
  24.  
  25. return $args;
  26. }
  27.  
  28. $url = 'http://www.google.co.nz/search?q=simon+rocks!&start=0&ie=utf-8&oe=utf-8&client=firefox-a&rls=org.mozilla:en-US:official';
  29.  
  30. $result = process_url( $url );
  31.  
  32. print_r( $result );

Will result in something like this:

PHP:
  1. (
  2. [q] => simon rocks!
  3. [start] => 0
  4. [ie] => utf-8
  5. [oe] => utf-8
  6. [client] => firefox-a
  7. [rls] => org.mozilla:en-US:official
  8. )