10个必须收藏的PHP代码样例 .docVIP

  • 7
  • 0
  • 约6.66千字
  • 约 33页
  • 2019-06-07 发布于北京
  • 举报
10个必须收藏的PHP代码样例 一、黑名单过滤 1.function is_spam($text, $file, $split = ‘:’, $regex = false){ 2. $handle = fopen($file, ‘rb’); 3. $contents = fread($handle, filesize($file)); 4. fclose($handle); 5. $lines = explode(n, $contents); 6.$arr = array(); 7.foreach($lines as $line){ 8.list($word, $count) = explode($split, $line); 9.if($regex) 10.$arr[$word] = $count; 11.else 12.$arr[preg_quote($word)] = $count; 13.} 14.preg_match_all(~.implode(’|’, array_keys($arr))。~, $text, $matches); 15.$temp = array(); 16.foreach($matches[0] as $match){ 17.if(!in_array($match, $temp)){ 18.$temp[$mat

文档评论(0)

1亿VIP精品文档

相关文档