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?
This works as expected… at least according to the manual of preg_replace.
This is needed as you can use
\\nfor back references. If you don’t want a back reference but want the\itself you need to escape it. If you want 3 backslashes you must write 6 backslashes.This will generate the following output.