Reply to Re: Best way to extract URL from random string?

Your name:

Reply:


Posted by BKDotCom on 02/09/07 21:02

On Feb 9, 2:15 pm, "deko" <d...@nospam.com> wrote:

> Are there any PHP functions that will help here? How to handle sub domains?
> International domains?
>
> Thanks in advance.

well, you found parse_url
you might want to use regular expressions as well

$long_string = 'A HREF="http://something.else.example.com/blah/?
joe=bob"';
if ( preg_match('|([^\s"\']*://[^\s"\']*)|',$long_string,$matches) )
{
$url = $matches[1]; // http://something.else.example.com/blah/?
joe=bob
$parts = parse_url($url);
if ( preg_match('/(.+)\.\w+\.\w+/',$parts['host'],$matches) )
echo $matches[1]; // something.else
}

[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

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