The example in this article describes the PHP implementation function that deletes any character in the string. Share to everyone for your reference. Specifically as follows:
function Delstr ($start, $end, $orgenStr)
{/
/Read the first part of the string to delete the character position, and assign to the $temp
//strpos the position where the read character is to appear for the second time
Substr reads the substring//echo $before that specifies the start and end positions
. —". $last;
$temp = $orgenStr;
while (Strpos ($temp, $start) && Strpos ($temp, $end)) {
$temp =substr ($temp, 0, Strpos ($temp, $start)). substr ($temp, Strpos ($temp, $end) +strlen ($end))
Reads the latter part of the string to remove the character position, and then joins the front and rear parts and assigns the value to $temp
//Returns the string at the end
$temp;
Application instance
$a = "aaaa12345678bbbbtttttttttttttttttttttaaaa12345678bbbb
Kkkkkkkkkkkkaaaa12345678bbbbttttttttttttttttttttt ";
$b = "1234";
$c = "5678";
Echo delstr ($b, $c, $a);
The output is:
Aaaabbbbtttttttttttttttttttttaaaabbbbkkkkkkkkkkkkaaaabbbbttttttttttttttttttttt
Ps:
General applications in the middle of 1234 and 5678 have dynamic content, can be deleted in bulk
Update: A circular deletion was added to delete all eligible strings.
I hope this article will help you with your PHP program design.