php method to delete a specific string: First create a PHP sample file; then use the "str_replace" function or "preg_replace" function to replace the specified string with nothing to delete the specific string.
Recommended: "PHP Video Tutorial"
You can use the str_replace function or preg_replace function to replace the specified string with Empty, that is to say, delete the specified string:
<?php $str = 'a123abc112233aaccdd321123abcd'; echo str_replace("123", "", $str); //输出:aabc112233aaccdd321abcd a123112233/aiezu.com/aaccdd321123d $str = 'a123abc112233/aiezu.com/aaccdd321123abcd'; echo preg_replace("#abc#i", "", $str); //输出:a123112233/aiezu.com/aaccdd321123d
The above is the detailed content of How to delete specific string in php. For more information, please follow other related articles on the PHP Chinese website!