note 83998 added to function.parse-url
| From: | CoolCoyote at osu1 dot php dot net | Date: | Mon, 23 Jun 2008 12:35:22 +0000 |
| Subject: | note 83998 added to function.parse-url | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-140735@lists.php.net to get a copy of this message | ||
based on the "laulibrius at hotmail dot com" function, this work for relatives url only:
<?php
function parseUrl($url) {
$r = "^(?:(?P<path>[\.\w/]*/)?";
$r .= "(?P<file>\w+(?:\.\w+)?)?)\.(?P<extension>\w+)?";
$r .= "(?:\?(?P<arg>[\w=&]+))?";
$r .= "(?:#(?P<anchor>\w+))?";
$r = "!$r!";
preg_match ( $r, $url, $out );
return $out;
}
print_r(parseUrl("../test/f.aq.php?p=1&v=blabla#X1"));
?>
returns:
Array
(
[0] => ../test/faq.php?p=1&v=blabla#X1
[path] => ../test/
[1] => ../test/
[file] => faq
[2] => faq
[extension] => php
[3] => php
[arg] => p=1&v=blabla
[4] => p=1&v=blabla
[anchor] => X1
[5] => X1
)
----
Server IP: 217.174.223.124
Probable Submitter: 86.206.73.124
----
Manual Page -- http://www.php.net/manual/en/function.parse-url.php
Edit -- https://master.php.net/note/edit/83998
Del: integrated -- https://master.php.net/note/delete/83998/integrated
Del: useless -- https://master.php.net/note/delete/83998/useless
Del: bad code -- https://master.php.net/note/delete/83998/bad+code
Del: spam -- https://master.php.net/note/delete/83998/spam
Del: non-english -- https://master.php.net/note/delete/83998/non-english
Del: in docs -- https://master.php.net/note/delete/83998/in+docs
Del: other reasons-- https://master.php.net/note/delete/83998
Reject -- https://master.php.net/note/reject/83998
Search -- https://master.php.net/manage/user-notes.php