$string='"/" is a SLASH';
$bold='s';
$string1=preg_replace('/'.$bold.'/i','<b>\0</b>', $string);I have the code above and it produces the result below.
“/” iS a SLASH
And the code below produces “/” is a SLASH.
$bold='A';
$string2=preg_replace('/'.$bold.'/i','<b>\0</b>', $string);
So far so good
However,
$bold='/';
$string=preg_replace('/'.$bold.'/i','<b>\0</b>', $string);
when the variable $bold is “/” itself like the code above, it produces a warning saying the below
[quote=“Andres_Vaquero, post:4, topic:293348, full:true”]
You would have to escape the one in the variable $bold not the other ones.
[/quote]As I tried the following code by your suggestion
$bold='\/';
string2=preg_replace('/'.$bold.'/i','<b>\0</b>', $string);
It works fine.
Thank you, Andres_Vaquero.