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

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

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-06 20:11:52
Original
1347 people have browsed it

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

回复内容:

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

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

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

没有 自己写一个

用正则试试。。。

Related labels:
php
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
Latest Issues
php data acquisition?
From 1970-01-01 08:00:00
0
0
0
PHP extension intl
From 1970-01-01 08:00:00
0
0
0
How to learn php well
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template