Note Submitter: ashleyriot at hotmail dot com
----
Thanks solenoid, I added a modification just in case the url hasn't got any parameters
function modifyURL($mod)
{
$url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
$query = explode("&", $_SERVER['QUERY_STRING']);
//NEW_CODE
$params = false;
if ( !empty($query) ){
$params = true;
}
// modify/delete data
foreach($query as $q) {
list($key, $value) = explode("=", $q);
if(array_key_exists($key, $mod)) {
if($mod[$key]) {
$url = preg_replace('/'.$key.'='.$value.'/', $key.'='.$mod[$key], $url);
} else {
$url = preg_replace('/&?'.$key.'='.$value.'/', '', $url);
}
}
}
// add new data
$params = "";
foreach($mod as $key => $value) {
if($value && !preg_match('/'.$key.'=/', $url)) {
//NEW_CODE
if ( $params ) {
$url .= '&'.$key.'='.$value;
} else {
$url .= '?'.$key.'='.$value;
$params = true;
}
}
}
return $url;
}
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.