I'm using the following function to search for words in a text file. The problem is that this function is case-sensitive. I don't want it to be case-sensitive! How can I make the function case-insensitive?
$url = 'files/file.txt';
$thedata = file_get_contents($url);
$lines = explode(PHP_EOL, $thedata);
$search = 'some search words';
$pattern = preg_quote($search, '/');
$pattern = "/^.*$pattern.*\$/m";
if(preg_match_all($pattern, $thedata, $matches)) {
echo implode('<br>', $matches[0]);
} else {
echo '<div class="message color-red">';
echo 'Didn\'t find anything on that search!';
echo '</div>';
}