This article mainly introduces the PHP function for deleting any character in a string. it involves php's string traversal and truncation operations, and has some reference value, for more information about how to delete any character in a string using PHP, see the following example. Share it with you for your reference. The details are as follows:
Function delStr ($ start, $ end, $ orgenStr) {// read the first part of the string to be deleted, and assigned to $ temp // the position at which the strpos character is read for the first time. // substr reads the substring at the specified start and end positions. // 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); // read the last part of the string to be deleted, and connect the front and back parts, and assign $ temp // return the final string} return $ temp;} // application instance $ a = "aaaa12345678bbbbtttttttttttttttttttttttaaaa12345678bbbb success"; $ B = "1234 "; $ c = "5678"; echo delStr ($ B, $ c, $ );
Output:
Bytes
PS:
Generally, applications have dynamic content in the middle of 1234 and 5678 and can be deleted in batches.
Update: Added loop deletion to delete all matching strings.
I hope this article will help you with php programming.