I’m getting a very strange error with preg_replace.
I’m using the following code:
$text=preg_replace('/(\s)?'.preg_quote($f).'(\s)?/','<a href="XXDDJJ" target="_blank">XXAAJJ</a>',$text);
However, it’s saying:
Warning: preg_replace(): Unknown modifier '/'
I’ve even swapped out $text (the third argument) with a random string, and it still gave me that error. I’ve isolated the error to that third argument by splitting the arguments into seperate lines, and it always points at the line with the last argument.
How can I fix this? Thank you!
You need to include your expression delimiter (
/) in thepreg_quote()call: