Home > Backend Development > PHP Tutorial > php有没有在字符串中插入一个字符串的函数呢?

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

WBOY
Release: 2016-06-06 20:11:52
Original
1299 people have browsed it

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

回复内容:

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

<code class="php"><?php $str = 'hello';
echo substr_replace($str, 'a', 3, 0); // helalo
?></code>
Copy after login

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

没有 自己写一个

用正则试试。。。

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template