You can easily replace a part of string at a given postion of a substring with the help of string function known as substr_replace
$string2="abcdefghijklmnop";
if (strpos($string2,"abcd")!==false)
{
$pos=strpos("abcd",$string2);
$len=strlen("abcd");
$newstring=substr_replace($string2,"ABCD",$pos,$len);
}
echo "<br>";
print_r($string2);
echo "
";
print_r($newstring);
So the output will become:
abcdefghijklmnop
ABCDefghijklmnop
0 Comment(s)