当前位置:Gxlcms > PHP教程 > php有没有在字符串中插入一个字符串的函数呢?

php有没有在字符串中插入一个字符串的函数呢?

时间:2021-07-01 10:21:17 帮助过:24人阅读

比如在hello的中间加一个a,foo('hello', 'a', 3)这样的

回复内容:

比如在hello的中间加一个a,foo('hello', 'a', 3)这样的

  1. <code class="php"><!--?php
  2. $str = 'hello';
  3. echo substr_replace($str, 'a', 3, 0); // helalo
  4. ?--></code>

这个貌似没遇到过~不如自己写一个函数通用就好了!

没有 自己写一个

用正则试试。。。

人气教程排行