TechForums - Computer and Technical Discussions

Full Version: Extract host from an URL
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ever wanted to extract the domain name from a long URL? Here is a simple code that will do this.

Code:
$url='http://www.webdomainsbroker.com/forum/webdesign-and-coding/';
if (isset($url)) {
    $ref = parse_url($url);
$uri = trim(eregi_replace('www.', '', $ref['host']));
echo $uri;
}

Reference URL's