$pos = strpos($matches[1], $respond);
should be:
$pos = stripos($matches[1], $respond);
strpos()
is case-sensitive, while stripos()
is case-insensitive.
Pergunta
I am working on a program that reads a text file, looks for a word and then depending on whether the word is found displays different outcome.
Is there a way to ignore the capital letters? So for example when I am looking for a word respond it will grab Respond, respond, RESPOND, ReSpOnd etc.
Code is:
<?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>";
?>
Thanks!