note 69925 deleted from function.parse-url by philip
| From: | philip@php.net | Date: | Sat, 17 Oct 2009 15:38:49 +0000 |
| Subject: | note 69925 deleted from function.parse-url by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-161835@lists.php.net to get a copy of this message | ||
Note Submitter: kjensen at nospam dot iaff106 dot com
----
Here is a simple extended version of ParseURL().
I needed to make a link that will be saved off site but point to different file
than the one creating the link.
So I needed to get the path without the file name so I could change the
file name.
Here it is:
<?php
function ParseURLplus($url){
$URLpcs = (parse_url($url));
$PathPcs = explode("/",$URLpcs['path']);
$URLpcs['file'] = end($PathPcs);
unset($PathPcs[key($PathPcs)]);
$URLpcs['dir'] = implode("/",$PathPcs);
return ($URLpcs);
}
$url = 'http://username:password@hostname/path/directory/file.php?arg=
value#anchor';
$URLpcs = ParseURLplus($url);
print_r($URLpcs);
?>
Now I can change the $URLpcs['file'] and then glue itback together to make
a new url.