PHP敏感字过滤
2015-08-28 00:00
676 查看
$f = file('words.txt'); $words = array(); foreach ($f as $w) { $words[] = preg_quote(trim($w), '/'); } $text = file_get_contents('text.txt'); $start = microtime(true); $reg = '/' . implode('|', $words) . '/S'; preg_match_all($reg, $text, $m); $result = array(); $total = 0; foreach ($m[0] as $w) { if (!isset($result[$w])) { $result[$w] = 1; } else { $result[$w]++; } $total++; } $end = microtime(true); echo $end - $start, "\n"; echo $total, "\n"; print_r($result);
words.txt里面加入av
text.txt里面加入have
相关文章推荐
- 树莓派安装TP-link wn725n网卡驱动
- php大力力 [029节] 做PHP项目如何下载js文件:使用腾讯浏览器把网上案例页面存储到本地
- php_array
- PHP读取网页文件内容的实现代码(fopen,curl等)
- 四大天王之内容提供者ContentProvider
- php常用函数总结2
- ubuntu下编译php扩展的时候报缺少pcre解决办法
- php中常用的函数
- 浅析PHP开发规范之性能优化
- Yii2 自定义组件
- ubuntu下使用phpstorm开发php程序
- php+mysql留言板(模仿qq空间留言板)
- PHP分页算法
- Yii2增、删、改、查
- Yii2中一些常用的参数
- STM32 Timer : Base Timer, Input Capture, PWM, Output Compare
- setAttribute和setParameter方法的区别
- php模式设计之 工厂模式
- php设计模式专题附源码(解释器模式、工厂方法模式、外观模式、装饰模式、建造者模式)
- tftp协议的实现