sunny03 发表于 2017-12-31 08:49:23

相濡以沫丶问情

  --------------------------------------------------------------------------------------------------
  $str = "百度http://www.baidu.com,腾讯http://www.qq.com,新浪http://www.sina.com.cn/";;
  $arr = array("/百度/", "/腾讯/", "/新浪/");
  $prg = '***';
  $str = preg_replace($arr, $prg, $str);
  echo $str;
  --------------------------------------------------------------------------------------------------
  $badword = array(
  '张三','张三丰','张三丰田'
  );
  $badword1 = array_combine($badword,array_fill(0,count($badword),'*'));
  $bb = '我今张张三张三张三张三张三天开着张三上张三班';
  $str = strtr($bb, $badword1);
  echo $str;
  ---------------------------------------------------------------------------------------------------------------------------------------------------------
  /*function transgress_keyword($content, $Sensitivewords){ //定义处理违法关键字的方法
  $keyword = $Sensitivewords; //定义敏感词
  $m = 0;
  for($i = 0; $i < count ( $keyword ); $i ++) {    //根据数组元素数量执行for循环
  //应用substr_count检测文章的标题和内容中是否包含敏感词
  if (substr_count ( $content, $keyword [$i] ) > 0) {
  $m ++;
  }
  }
  return $m;            //返回变量值,根据变量值判断是否存在敏感词
  }
  if (transgress_keyword($detail, $Sensitivewords)> 0) {    //判断返回值大于0说明包含敏感词
  echo "<script>alert('您输入的内容中含有敏感词');</script>";
  }*/
  //-----------------------------------------------------------------------------------------------------------
  /*$num = 0;//定义子串出现次数
  //内容
  $content=$detail;
  //循环检测
  for($i = 0; $i < count($Sensitivewords); $i ++) {
  //计算子串在字符串中出现的次数
  if (substr_count ($content, $Sensitivewords[$i]) > 0) {
  $num ++;
  }
  }
  if($num>0){
  echo "有敏感词存在!";
  }*/
  //-----------------------------------------------------------------------------------------------------------
  /*$blacklist="/".implode("|",$Sensitivewords)."/i";
  if(preg_match($blacklist, $detail, $matches)){
  print "found:". $matches;
  } else {
  print "not found.";
  }*/
页: [1]
查看完整版本: 相濡以沫丶问情