Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

266 Posts in 126 Topics- by 44 Members - Latest Member: wildbad

January 06, 2009, 09:44:16 AM
  Google ads

11,000,000 Global IP Unique Visitors $1950.00

Bookmark and Share
WebMasters ForumDesign & DevelopmentWebDesign and Coding[PHP] Extract host from an URL
Pages: [1]   Go Down
Print
Author Topic: [PHP] Extract host from an URL  (Read 265 times)
0 Members and 1 Guest are viewing this topic.
Joseph
Administrator
Trade Count: (1)
*****
Online Online

Posts: 138



View Profile WWW
« on: July 27, 2008, 04:17:19 PM »

Ever wanted to extract the domain name from a long URL? Here is a simple code that will do this.

Code:
<?php
$url
='http://www.webdomainsbroker.com/forum/webdesign-and-coding/'// here is an URL
if (isset($url)) { // if the URL is set (is already set above)
$ref parse_url($url); // parse the URL
$uri trim(eregi_replace('www.'''$ref['host'])); // remove the www. from the host.
echo $uri// print the host name
}
?>
« Last Edit: December 25, 2008, 10:08:04 PM by Joseph » Logged

Pages: [1]   Go Up
Print
Jump to:  

Forex online. Without it, you are wasting your time (and money).
Forex trading involves substantial risk of loss, and may not be suitable for everyone.