gpt4 book ai didi

php - PHP如何使用strpos不区分大小写?

转载 作者:可可西里 更新时间:2023-11-01 13:47:01 27 4
gpt4 key购买 nike

我制作了一个 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);
}
?>

最佳答案

是的,stripos() 就是您要找的。这是 the manual page .

关于php - PHP如何使用strpos不区分大小写?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31487263/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com