I am trying to replace a the content of href attribute with another URL
So I use this script
$html = 'data-content="111"';
$var_2 = "222";
$html = preg_replace('/(["\'])111\1/i',"$1$var_2$1",$html);
echo $html
The output was
data-content=22"
What I was expecting
data-content="222"
The problem is that the compiler look for match $12 because $var_2 start with the number "2"
I tried to edit the code like this but no luck
$html = preg_replace('/(["\'])111\1/i','$1'.$var_2.'$1',$html);