Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Extract url from this string? It should be flexible for all
strings, not for this string only.
"yahoo.comyahoo.co.inhotmail.org"

Answer Posted / amitverma

##
##This will work for PHP 5.3 -

$url1="yahoo.com";
$url2="yahoo.co.in";
$url3="hotmail.org";

$domain1 = strstr($url1, '.', true);
$domain2 = strstr($url2, '.', true);
$domain3 = strstr($url3, '.', true);

echo $domain1, $domain2, $domain3;


##
## For Older PHP (<5.2.8), this code will follow -
$url1="yahoo.com";
$url2="yahoo.co.in";
$url3="hotmail.org";

$domain1 = substr($url1, 0, strpos($url1, '.') );
$domain2 = substr($url2, 0, strpos($url2, '.') );
$domain3 = substr($url3, 0, strpos($url3, '.') );

echo $domain1, $domain2, $domain3;


Is This Answer Correct ?    2 Yes 8 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Suppose your zend engine supports the mode Then how can you configure your php zend engine to support Mode ?

924


What is the interface in php?

979


How variables are passed through arguments?

898


discuss the issue of software theft in ghana and how it has affected the economy

2053


Why namespace is used in php?

940


armstrong number by using php while number is given by the keyboard.?

2125


What is php explain?

899


What is default session time in php?

909


What will the ?getdate() function returns in PHP?

1027


How to count all the lines of code in a directory and sub folder?

926


Explain Booleans in PHP?

1035


Tell me what's the difference between include and require?

925


What is the difference between rest and soap?

1046


How can you retrieve a cookie value?

1011


What are the file upload settings in configuration file?

981