1. 目录
  2. 锚点

过滤符号、过滤词组

首页 > PHP > 原生PHP 更新日期:2022-12-29 10:20:13

过滤符号

/**
 * 过滤符号
 * $str 字符串
 */
function Guolv_1 ($str) {
    $regex = "/\/|\~|\!|\@|\#|\\$|\%|\^|\&|\*|\(|\)|\_|\+|\{|\}|\:|\<|\>|\?|\[|\]|\,|\.|\/|\;|\'|\`|\-|\=|\\\|\|/";
    return preg_replace($regex,"",$str);
}

过滤某些词组

/**
 * 过滤某些词组
 * $str 字符串
 */
function guolv_2($str){
    $str = str_replace(' ', '', $str);
    $str = str_replace('”', '', $str);
    $str = str_replace('“', '', $str);
    $str = str_replace('…', '', $str);
    return trim($str);
}