I am trying to search in a txt file using php. It is supposed to search the txt file and display results that it got from the file.
Here is my php
code:
<?php
$file = 'my file.txt';
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if(preg_match_all($pattern, $contents, $matches)){
echo "Found matches:
";
echo implode("
", $matches[0]);
}
else {
echo "No matches found";
}