/** * Takes a full URL, $url, possibly with a querystring and overlays the $getParams arrays values onto the quirystring, packs it all together and returns the URL again. * So basically it adds the parameters in $getParams to an existing URL, $url * * @param string $url URL string * @param array $getParams Array of key/value pairs for get parameters to add/overrule with. Can be multidimensional. * @return string Output URL with added getParams. */ public static function linkThisUrl($url, array $getParams = array()) { $parts = parse_url($url); $getP = array(); if ($parts['query']) { parse_str($parts['query'], $getP); } ArrayUtility::mergeRecursiveWithOverrule($getP, $getParams); $uP = explode('?', $url); $params = self::implodeArrayForUrl('', $getP); $outurl = $uP[0] . ($params ? '?' . substr($params, 1) : ''); return $outurl; }