php 界面搜索框搜索指定目录的文本,如何不使用数据库进行搜索?
|
loadingNov 15, 2016 via Android
1
文本不大就 file open 到内存
文本大就调用 linux 命令 |
|
barberyNov 15, 2016
2
glob
|
|
m939594960Nov 15, 2016
3
https://stackoverflow.com/questions/14301895/finding-files-with-a-certain-string 这个回答
··· $searchDir = './'; $searchString = 'a test'; $result = shell_exec('grep -Ri "'.$searchString.'" '.$searchDir); echo '<pre>'.$result.'</pre>'; ··· |
|
alex321Nov 15, 2016
4
shell_exec
|
|
vibbowNov 15, 2016
5
https://gist.github.com/vibbow/a56d54fa08bb66501f852b6dfd2e9d49
5 年前写的代码, LZ 可以试着理解一下...... 基本上可以以磁盘极限速度搜索。 |