使用preg_place删除URL中的&;和空格 [英] Remove & and Whitespace in URL with preg_replace
本文介绍了使用preg_place删除URL中的&;和空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
preg_replace('/s+/', '-', $page->label) // whitepace gets replaced with -
preg_replace('/&/', '-', $page->label) // & gets replaced with -
我希望将这两个放在一行中,但我无法将这两个组合在一起。有人能帮忙吗? 提前非常感谢您。
推荐答案
这应该可以很好地将所有内容保持在一行中。
$output = preg_replace('/s+|&/', '-', $page->label);
这篇关于使用preg_place删除URL中的&;和空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文