PHP preg_replace without eval
Posted
by Alec Smart
on Stack Overflow
See other posts from Stack Overflow
or by Alec Smart
Published on 2010-06-03T11:21:54Z
Indexed on
2010/06/03
11:24 UTC
Read the original article
Hit count: 350
php
Am trying to use something like:
$newdata = preg_replace($pattern, $replacement, $data);
Now my replacement is something like
$pattern = "/START(.*?)END/is";
$replacement = "START $config END";
Now, $config contains contents like
array('Test\\\'s Page')
The problem is that after I write the content, $newdata becomes
START array('Test\\'s Page') END
As you see above a single \ goes missing because it gets evaluated. How do I avoid that?
© Stack Overflow or respective owner