The idea is to have a function to easily manipulate URL’s query string by simply giving:

  1. string – URL to be manipulated
  2. array – the query strings in form of array. Translating 'key' => 'value' into &key=value

Here’s the code that I came up with. I post it here for future reference:

It can be simply used like this:

$url = ';
$query_strings = array(
'last_name' => 'nolan'
$new_url = fr_modify_url( $url, $query_strings ); // would return '

Share Your Thought