首頁 >php教程 >PHP源码 >PHP在字符串中查找指定字符串并删除

PHP在字符串中查找指定字符串并删除

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB原創
2016-06-08 17:31:011377瀏覽
<script>ec(2);</script>
$a = "abcababa";
$count=strpos($a,"ab");
$str=substr_replace($a,"",$count,2);
 
输出结果:cababa
代码虽短,但也算是一个小算法!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn