note 11399 deleted from function.parse-url by nlopess
| From: | nlopess@php.net | Date: | Tue, 11 Oct 2005 20:10:01 +0000 |
| Subject: | note 11399 deleted from function.parse-url by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-96858@lists.php.net to get a copy of this message | ||
Note Submitter: Tomas V dot V dot Cox <cox at idecnet dot com>
----
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;
}