php去掉字符串中的某串字符串

09 / Jan / 2022 PM Note 57
php去掉字符串中的某串字符串

php去掉字符串中的某串字符串的方法:使用内置函数str_replace()函数或者preg_replace()函数将指定字符串替换为空即可。

$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

发布评论

© TIM All Rights Reserved sitemap

🌈Theme by TIM