我们正在尝试从字符串中转义一些特殊字符,请告诉我我们必须使用的函数\ne.g。HTC Desire 210 \xe2\x80\x93 白色
\n在此示例中,我们转义 -(连字符)特殊字符。\n在上面的示例中,我们有很多具有不同特殊字符的产品名称,我们对其进行转义。\n感谢您的合作。
在此函数中传递字符串。
function clean($string){
$string = str_replace(' ', '-', $string); // Replaces spaces with hyphens.
return preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
}
Run Code Online (Sandbox Code Playgroud)
有关更多信息,请检查此删除特殊字符 - Stackoverflow
| 归档时间: |
|
| 查看次数: |
61535 次 |
| 最近记录: |