PHP string traversal and interception operation skills

墨辰丷
Release: 2023-03-30 14:22:01
Original
2590 people have browsed it

This article mainly introduces PHP string traversal and interception operation skills. Interested friends can refer to it. I hope it will be helpful to everyone.

The details are as follows:

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);
Copy after login

The output is:

aaaabbbbttttttttttttttttttttaaaabbbbkkkkkkkkkkkkaaaabbbbtttttttttttttttttttttt

##Summary: That’s it for this article The entire content of the article is hoped to be helpful to everyone's study.

Related recommendations:

php class automatic loading, chain operation, magic method implementation code_php skills

PHP Detailed explanation of several methods to achieve page staticization

PHP practical tutorial methods of filtering, verification, escaping and password

The above is the detailed content of PHP string traversal and interception operation skills. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!