我制作了一个php脚本,在其中搜索包含文本文件的整个目录,一切正常,但区分大小写。如果没有区分大小写,我将如何搜索?这是我到目前为止的代码:
<?php
$query = $_POST['search'];
if ($handle = opendir('posts')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
echo "<p>$entry ";
$file = file_get_contents('posts/'.$entry, FILE_USE_INCLUDE_PATH);
$check_str = strpos($file,$query);
if ($check_str == 0) {
print "not found</p>";
} else {
print "found</p>";
}
}
}
closedir($handle);
}
?>