php 删除字符串中任何字符的方法-PHP问题

资源魔 27 0

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);

输入后果:

4256ba7070889aa4a51f96e0047e01d.png

保举:《PHP教程》

以上就是php 删除了字符串中任何字符的办法的具体内容,更多请存眷资源魔其它相干文章!

标签: php php教程 php故障解决 php使用问题

抱歉,评论功能暂时关闭!