需要一些帮助升级一小部分 ereg_replace
我有这行代码用于 SEO 目的。唯一的事情是它有一个 ereg_replace 函数。现在我收到“ereg_replace() 已弃用”错误。
显然这并不像切换到 preg_replace 那么简单,而且我的 RegEx-fu 也不是太强大。任何帮助将不胜感激。
谢谢。
//make it lowercase, remove punctuation, remove multiple/leading/ending spaces
$return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));
I have this line of code I use for SEO purposes. The only thing is that it has an ereg_replace function in it. Now I get "ereg_replace() is deprecated" error.
Apparently it's not as simple as switching it to preg_replace and my RegEx-fu is not too strong. Any help would be highly appreciated.
Thanks.
//make it lowercase, remove punctuation, remove multiple/leading/ending spaces
$return = trim(ereg_replace(' +',' ',preg_replace('/[^a-zA-Z0-9\s]/','',strtolower($input))));
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
干得好。
Here you go.
您只需添加分隔符
ereg_replace(' +'
变为preg_replace('/ +/'
You just need to add delimeters
ereg_replace(' +'
becomespreg_replace('/ +/'