Re: Extract links from strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 21, 2009 at 12:52:12PM -0300, Jônatas Zechim wrote:

> Hi there, i've the following strings:
> 
> $string1 = 'Lorem ipsum dolor http://site.com sit amet';
> $string2 = 'Lorem ipsum dolor http://www.site.com/ sit amet';
> $string3 = 'Lorem ipsum dolor http://www.site.net sit amet';
> 
> How can I extract the URL from these strings?
> They can be [http:// + url] or [www. + url].
> 

Use the preg_match() function (see
http://us2.php.net/manual/en/function.preg-match.php ) and a good
regular expression from a place like http://www.regexlib.com/ .

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux