PHP 从字符串中删除特殊字符“%”
PHP remove special character '%' from string
我想删除“%”
echo '<a href="/coupon/'.$post->slug.'/'.$dcount.'/'.strtolower(str_replace(' ','-', $drow['title'])).'" target="_blank">';
有什么建议吗?谢谢
str_replace([' ','%'], ['-','%'], $drow['title']);
str_replace
允许您指定多个替换,如上所述。不确定你想用什么替换 %
所以我放了 %
这是 %
.
的 HTML-转义符号
使用 preg_replace
代替正则表达式
preg_replace('/[ %]/','-', $drow['title']))
了解 preg_replace
: http://php.net/manual/en/function.preg-replace.php
我想删除“%”
echo '<a href="/coupon/'.$post->slug.'/'.$dcount.'/'.strtolower(str_replace(' ','-', $drow['title'])).'" target="_blank">';
有什么建议吗?谢谢
str_replace([' ','%'], ['-','%'], $drow['title']);
str_replace
允许您指定多个替换,如上所述。不确定你想用什么替换 %
所以我放了 %
这是 %
.
使用 preg_replace
代替正则表达式
preg_replace('/[ %]/','-', $drow['title']))
了解 preg_replace
: http://php.net/manual/en/function.preg-replace.php