Possible Duplicate:
Change single variable value in querystring
i belirli bir url bir parametre eklemek veya güncellemek için bu işlevi bulundu parametre ilave edilmesi gerektiğinde, çalışır, ancak parametre varsa onu yerine geçmez - üzgünüm ben regex hakkında çok şey bilmiyorum herkes lütfen bir bak:
function addURLParameter ($url, $paramName, $paramValue) {
// first check whether the parameter is already
// defined in the URL so that we can just update
// the value if that's the case.
if (preg_match('/[?&]('.$paramName.')=[^&]*/', $url)) {
// parameter is already defined in the URL, so
// replace the parameter value, rather than
// append it to the end.
$url = preg_replace('/([?&]'.$paramName.')=[^&]*/', '$1='.$paramValue, $url) ;
} else {
// can simply append to the end of the URL, once
// we know whether this is the only parameter in
// there or not.
$url .= strpos($url, '?') ? '&' : '?';
$url .= $paramName . '=' . $paramValue;
}
return $url ;
}
Burada işe yaramazsa ne bir örnek:
http://www.mysite.com/showprofile.php?id=110&l=arabic
i l = İngilizce ile addURLParameter ararsanız, ben olsun
http://www.mysite.com/showprofile.php?id=110&l=arabic&l=english
şimdiden teşekkürler.