You are here: Re: [PHP] help with preg_replace only part of the string « PHP « IT news, forums, messages
Re: [PHP] help with preg_replace only part of the string

Posted by Richard Heyes on 12/06/05 13:06

Georgi Ivanov wrote:
> Hi,
> I want to replace the content of html links : <a href="foo"
> name="bla">REPLACETHIS</a>.
>
> $html=preg_replace("/(<a.*name=.*>)(.*)<\/a>/isU",$link,$html,1);
> This generally works but removes <a>,</a> tags too.
> How to make it work without removing anything else than (.*) in the middle of
> <a>.*</a>

$html = preg_replace("/(<a.*name=.*>)(.*)<\/a>/isU", '\1' . $link .
'</a>', $html, 1);

--
Richard Heyes
http://www.phpguru.org

 

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

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