3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str ="it is a test string."; $y="r"; $x="m"; $len=strlen($str); if($str[0]==$y) { $str=substr_replace($str,$x,0,1); } if($len>=3) { for($i=3;$i<$len;$i+=4) { if($str[$i]==$y) { $str=substr_replace($str,$x,$i,1); } } } var_dump($str);
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.30, 8.2.0 - 8.2.25, 8.3.0 - 8.3.13
string(20) "it is a test stming."

preferences:
75.14 ms | 408 KiB | 5 Q