Parsing URL query and appending it at end of the other URL
I'd write it like this 

function concatQueryVars($first, $second) {
    $url = strtok($first, '?');
    $first = parse_url($first, PHP_URL_QUERY);
    $second = parse_url($second, PHP_URL_QUERY);
    return !empty($url) &amp;&amp; 
           !empty($first) &amp;&amp; 
           !empty($second) 
           ? $url . '?' . $first. '&amp;' . $second : false;
}

echo concatQueryVars('http://example.com/?a=b', 'http://example.com/?c=d&amp;e=f');


Result:


  http://example.com/?a=b&amp;c=d&amp;e=f