You are here: Re: preg_replace « PHP Programming Language « IT news, forums, messages
Re: preg_replace

Posted by Raj on 10/26/39 11:33

"Philip Ronan" <invalid@invalid.invalid> wrote in message
news:BFB37AB7.3BC85%invalid@invalid.invalid...
> "Raj" wrote:
>
>> $tmp = preg_replace('/<!-- (\S+) -->/ge', $values[\\1], $line);
>>
>> The template file will have lines such as:
>>
>> <image source="pics/<!-- pic1 -->" thumb="pics/<!-- thumb1 -->"
>> title="<!-- caption1 -->"/>
>>
>> And the $values array has values:
>>
>> $values[pic1] = "raj1.jpg"
>> $values[thumb1] = "traj1.jpg"
>> $values[caption1] = "Who is this?"
>>
>> Can anyone see where I am going wrong?
>
> Try $values['\1'] instead of $values[\\1]. Looks OK otherwise.

Thanks Phil, however it still does not do the replacement. Is there an easy
way I can print the value of the match? and does the replace function
substitue greedily? i.e. will it replace all three placeholders on on line?

Thanks!

Raj

 

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

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