note 69925 added to function.parse-url

From: Date: Tue, 26 Sep 2006 23:21:01 +0000
Subject: note 69925 added to function.parse-url
Groups: php.notes 
Request: Send a blank email to php-notes+get-117701@lists.php.net to get a copy of this message
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. ---- Server IP: 64.71.164.2 Probable Submitter: 24.17.156.134 ---- Manual Page -- http://www.php.net/manual/en/function.parse-url.php Edit -- https://master.php.net/note/edit/69925 Del: integrated -- https://master.php.net/note/delete/69925/integrated Del: useless -- https://master.php.net/note/delete/69925/useless Del: bad code -- https://master.php.net/note/delete/69925/bad+code Del: spam -- https://master.php.net/note/delete/69925/spam Del: non-english -- https://master.php.net/note/delete/69925/non-english Del: in docs -- https://master.php.net/note/delete/69925/in+docs Del: other reasons-- https://master.php.net/note/delete/69925 Reject -- https://master.php.net/note/reject/69925 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#117701) next »