note 11399 modified in parse_url by ronabop
| From: | ronabop@php.net | Date: | Sun, 25 Feb 2001 01:28:35 +0000 |
| Subject: | note 11399 modified in parse_url by ronabop | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-11544@lists.php.net to get a copy of this message | ||
Perhaps someday you need to modify somefield from the parse_url() and then build the url again with
this data.
To make it, here I post the "glue_url" function:
// param $url is the result array from the parse_url()
function glue_url ($url){
if (!is_array($url)){
return false;
}
// scheme
$uri = (!empty($url['scheme'])) ? $url['scheme'].'://' :
'';
// user & pass
if (!empty($url['user'])){
$uri .= $url['user'].':'.$url['pass'].'@';
}
// host
$uri .= $url['host'];
// port
$port = (!empty($url['port'])) ? ':'.$url['port'] : '';
$uri .= $port;
// path
$uri .= $url['path'];
// fragment or query
if (isset($url['fragment'])){
$uri .= '#'.$url['fragment'];
} elseif (isset($url['query'])){
$uri .= '?'.$url['query'];
}
return $uri;
}
http://www.php.net/manual/parse-url.php