parse_url
This would have to be one of the most useful functions that I’ve ever stumbled across. It’s called parse_url, and it accepts a string representation of a URL:
array parse_url ( string url)
It returns an associative array containing the various parts of the URL, such as the protocol, host, port, path, query string, etc. This function could come in handy when you require a user to enter a valid URL for something like a competition, feedback form, etc.
The parse_url function is simple enough, and can be used like this:
<?php
$myDomain= parse_url(”http://www.devarticles.com/?param1=blah#bottom”);
echo “Domain: ” . $myDomain[”host”] ;
echo “Query String: ” . $myDomain[”query”] ;
echo “Anchor: ” . $myDomain[”fragment”] ;
?>
