步骤一:先获取字符串第一次出现的位置( strpos() );
步骤二:获取需替换字符长度( strlen() );
步骤三:替换字符
字符串:abcdefgabchijklmn
查找对象:abc
替换内容:123
最终效果:123defgabchijklmn
$str = "abcdefgabchijklmn";
$needle = "abc";
$result = substr_replace($str,"123",strpos($str,$needle),strlen($needle));
var_dump($result);
https://blog.csdn.net/qq_35600509/article/details/54410471