您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 删除字符串中任何字符的方法

2025/12/17 14:14:23发布21次查看
php 删除字符串中任何字符的方法 
function delstr($start, $end, $orgenstr) { //读取要删除字符位置的前一部分字符串,并赋值给$temp //strpos读取字符第一次出现的位置 //substr读取指定开始与结束位置的子字符串 //echo $before."—". $last; $temp=$orgenstr; while(strpos($temp, $start) && strpos($temp, $end)){ $temp=substr($temp, 0, strpos($temp, $start)).substr($temp,strpos($temp, $end)+strlen($end));; //读取要删除字符位置的后一部分字符串,然后将前后部分连接,并赋值给$temp //返回最后是字符串 } return $temp; } //应用实例 $a="aaaa12345678bbbbtttttttttttttttttttttaaaa12345678bbbb kkkkkkkkkkkkaaaa12345678bbbbttttttttttttttttttttt"; $b="1234"; $c="5678"; echo delstr($b,$c,$a);
输出结果:
推荐:《php教程》
以上就是php 删除字符串中任何字符的方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product