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

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

"Philip Ronan" <invalid@invalid.invalid> wrote in message
news:BFB38A19.3BC8D%invalid@invalid.invalid...
> "Raj" wrote:
>
>> "Philip Ronan" <invalid@invalid.invalid> wrote in message
>> news:BFB37AB7.3BC85%invalid@invalid.invalid...
>>>
>>> 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?
>
> I just noticed you're also using unquoted text in the $values
> declarations.

No, that was just an example of the values, for illustration, but they are
assigned by the $_POST'd values in a loop.

> Change $values[pic1] to $values['pic1'], etc. You should also put this
> line
> at the beginning of your script:
>
> error_reporting(E_ALL);

Thanks, that's a useful command.

> That will help you find any other mistakes. You don't need to worry about
> greedy matches because \S will stop matching at the first space character.

Ok, but I want to replace all occurrences of the placeholder that occur on a
line with the corresponding value from the $values array.

Changing $values[\\1] to $values['\1'] gives the following error:

Notice: Undefined index: \1 in
/hsphere/local/home/oneconcept/oneconcept.net/honeymoon/gallery_upload.php
on line 66

and no substitution occurs.

Any more ideas? :O)

Thanks again
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

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