tags:

views:

18

answers:

1

Hello there i've finally made a good perfect language system and now am trying to fix my templates system to work with this new language system =P i want to replace to $tag['$thepreviousvalue'] so i made the following code

preg_replace("/<LANGUAGE value=\"^[a-zA-Z0-9_]{1,}$\">/si", ''. $langvals['$1'] .'', $data);

but it doesn't work and i bet that my weak knowledge in regexp is the problem Best Regards

+1  A: 
preg_replace('/your_regex/e', '$var[\'$1\']', $string);

In your case:

preg_replace('/<LANGUAGE value="([a-z0-9_]+?)">/ei', '$langvals[\'$1\']', $data);

You can read more about the "e" modifier at php.net.

Also, I fixed your regex.

Mewp
OOOO yea that works <3 love ya bro
SAFAD
*(suggested reading)* [Regular Expression Injection (PDF)](http://hauser-wenz.de/playground/papers/RegExInjection.pdf)
Gordon
oh Gordon, thanks for the book...it has Great info to know BUT,i think there is no risk here...am replacing language tag with its value thats all, and there is no Post Or Get here, just a regular use in templates...maybe you have another idea
SAFAD
@SAFAD that depends on the viewpoint. From a pragmatic POV this is nothing to bother if you are the only one authoring the tags, but from a less situational POV the code is dangerous.
Gordon