You are here: Re: Extract any URL from any string? « PHP Programming Language « IT news, forums, messages
Re: Extract any URL from any string?

Posted by Janwillem Borleffs on 02/11/07 11:14

deko wrote:
> so I have a few undefined variables... I thought this did not matter
> with PHP (script vs. compiled code)
>

It doesn't, but it's just good practice to do so (and increasing the
error_reporting level saves you a lot of time debugging when making typos in
variable names).

> well, if urlString = http://netforex.subdomain.net.foo'>,
> parse_url() returns: netforex.subdomain.net.foo'> - which is not much
>

The parse_url function can indeed easily be fooled, so you will have to add
some additional validation. But it's quite useful for what you are doing
(and pretty fast).

> I was able to replace an eregi with preg_match on lines 18 and 29,
> but unsure of the syntax for line 44 ... suggestions?
>

You mean the following line?

> if (eregi("^(com|net|org...)$", $urlString_a[$i]))

You can simply replace this with:

> if (preg_match("!^(com|net|org...)$!i", $urlString_a[$i]))


JW

 

Navigation:

[Reply to this 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

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