How to replace sub-string in PHP

1 Answer

0 votes
$s = "http equiv content type";
echo $s . "<br>"; // http equiv content type

$r = substr_replace($s, "**", 5);
echo $r . "<br>"; // http **

$r = substr_replace($s, "**", 5, 2);
echo $r . "<br>"; // http **uiv content type

$r = substr_replace($s, "**", 5, 8);
echo $r . "<br>"; // http **ntent type

$r = substr_replace($s, "**", 5, 0);
echo $r . "<br>"; // http **equiv content type

$r = substr_replace($s, "HTML", 5, 5);
echo $r . "<br>"; // http HTML content type


answered Jun 14, 2014 by avibootz
...