Reply to Re: replacing www... with hyperlink

Your name:

Reply:


Posted by monomaniac21 on 08/08/06 14:38

well i figured out my own way of doing this cos the problem kept
bugging me and ive added her for anyone else who is interested. if
anyone else knows of a more efficient way id love to hear it. im not
sure but i think exploading a string then searching each array value
might be bettered by a function that just performed a search and
replace on the string.

$para1 = "sdfsdf dsf dsfsd www.dsafads.com";
$para1_arr = explode(' ',$para1);
$i = 0;
foreach ($para1_arr as $value) {
$newarr[$i] = $value;
if (strstr($value, 'www.') != FALSE) {
$value = "<a href='http://$value'>$value</a>";
$newarr[$i] = $value;
}
$i = $i + 1;
}
$para1 = implode(' ', $para1);




Ciaran wrote:
> monomaniac21 wrote:
> > hi all i want to replace all entries of beginning with 'www.' and
> > ending with ' ' with a hyperlink to that substring such as:
> >
> > www.google.com := <a href="www.google.com">www.google.com</>
> >
> > can anyone tell me the easiest way to do this?
>
> You'll want to put an 'http://' in the href attribute, too.
>
> The best way to do this is to use preg_replace, see the manual at
> http://php.net/preg_replace.
>
> -Ciaran

[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

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