php删除字符串中的指定字符串的方法:1、利用strpos函数查找字符串的位置;2、利用strlen函数计算字符串的长度;3、利用substr_replace函数替换指定字符串即可。

相关函数介绍:
(推荐教程:php视频教程)
strlen() 函数返回字符串的长度。
strpos()函数查找字符串在另一字符串中第一次出现的位置(区分大小写)。
立即学习“PHP免费学习笔记(深入)”;
substr_replace()函数把字符串的一部分替换为另一个字符串。
实现代码:
$ex = 'http://img.path.com'; $email= 'http://img.path.com/uploads/20190723/c700499be56d6a97c32985bda0c7745b.png'; $count=strpos($email,"$ex"); $strlen = strlen($ex); $str=substr_replace($email,"",$count,$strlen); echo $str;
相关推荐:php培训
以上就是php如何删除字符串中的指定字符串的详细内容,更多请关注php中文网其它相关文章!
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号