note 83875 deleted from function.parse-url by cmb

From: Date: Sun, 16 Jun 2019 08:24:45 +0000
Subject: note 83875 deleted from function.parse-url by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-211286@lists.php.net to get a copy of this message
Note Submitter: laulibrius at hotmail dot com ---- There was one thing missing in the function dropped by "to1ne at hotmail dot com" when i tried it : domain and subdomain couldn't have a dash "-". So i add it in the regexp and the function looks like this now : <?php function parseUrl($url) { $r = "^(?:(?P<scheme>\w+)://)?"; $r .= "(?:(?P<login>\w+):(?P<pass>\w+)@)?"; $r .= "(?P<host>(?:(?P<subdomain>[-\w\.]+)\.)?" . "(?P<domain>[-\w]+\.(?P<extension>\w+)))"; $r .= "(?::(?P<port>\d+))?"; $r .= "(?P<path>[\w/]*/(?P<file>\w+(?:\.\w+)?)?)?"; $r .= "(?:\?(?P<arg>[\w=&]+))?"; $r .= "(?:#(?P<anchor>\w+))?"; $r = "!$r!"; // Delimiters preg_match ( $r, $url, $out ); return $out; } ?> Btw, thanks for the function, it helps me a lot.

« previous php.notes (#211286) next »