if语句-在PHP中读取文件时忽略大写字母


if statement - Ignoring capital letters when reading from file in PHP

我正在编写一个程序,它读取一个文本文件,查找一个单词,然后根据是否找到该单词显示不同的结果。

有办法忽略大写字母吗?例如,当我要查找一个单词时它会抓取response, response, respond, respond, respond等等

代码是:

<?php
//1 email;
$file = "1.txt";
$fh = fopen($file, 'r');
$theData = fread($fh, filesize($file));
fclose($fh);
echo "<strong>Email 1 - correct outcome: reply needed <br /></strong>"; 
if (preg_match("/dota(.*?)dota1/s", $theData, $matches))
{
    echo $matches[1]."<br />";
}
$respond   = 'Respond';
$pos = strpos($matches[1], $respond);
if ($pos === false) {
    echo "Reply not needed";
} else {
    echo "Reply needed";
}
echo "<HR>"; 
?>  

谢谢!

$pos = strpos($matches[1], $respond);
应:

$pos = stripos($matches[1], $respond);

strpos()区分大小写,stripos()不区分大小写。