Reply to How to extract domain from string with regex?

Your name:

Reply:


Posted by deko on 12/17/68 11:56

I'm sure someone has passed this way before...

I want to check to see is a domain name is contained in a string, and if one is,
I want to extract it. In these strings, domains are always preceded by
"http://" or "http : //www" (without the spaces).

in pseudo code, I thought it might look like this:

if (eregi("http: //", $mystring))
{
$domain = explode("http: //", $mystring);
$domain = array_reverse($domain);
}
$parts = domain[0];
explode(".", $parts);
if ($parts[0] == "www")
{
$extracted = $parts[1]."."$parts[2];
}
else
{
$extracted = $parts[0]."."$parts[1];
}

Does this look about right?

Thanks in advance.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация