You are here: Re: string http:// conwert to <a href=''>host</a> « PHP Programming Language « IT news, forums, messages
Re: string http:// conwert to <a href=''>host</a>

Posted by Janwillem Borleffs on 11/27/32 11:29

specjal wrote:
> Warning: Unknown modifier '/'
> what is wrong?
>
> $tresc = preg_replace('/(http)(s?)(://)([^ ]+)/', '<a
> href="$1$2$3$4">$1$2$3$4</a>', tresc);
>

The slashes are used as modifiers to mark the beginning and the end of the
pattern, but they are also used in the pattern itself.

You can fix this by escaping the slashes in the pattern:

$tresc = preg_replace('/(http)(s?)(:\/\/)([^ ]+)/', '<a
href="$1$2$3$4">$1$2$3$4</a>', tresc);

Or by using another modifier:

$tresc = preg_replace('#(http)(s?)(://)([^ ]+)#', '<a
href="$1$2$3$4">$1$2$3$4</a>', tresc);


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

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