parse_url() function can parse a URL and return its component parts. It is used as follows: array parse_url ( string url )This function returns an associative array containing the various components of the existing URL. If one of these components is missing, no array entry will be created for this component. The components are:
This function does not mean that the given URL is valid, it just separates the parts in the list above. parse_url() accepts incomplete URLs and tries to parse them correctly. This function has no effect on relative path URLs.
Array ( [scheme] => http [host] => www.nowamagic.net [path] => /welcome/ )
< ;?php
Array ( [scheme] => http [host] => hostname [user] => username
echo parse_url($url, PHP_URL_PATH); Copy code
|