Right now it's only searching through one text file but I want it to search through a whole directory but I don't know how to go about that :/
<?php
$searchfor = "example";
$file = 'file.txt';
$contents = file_get_contents($file);
$pattern = preg_quote($searchfor, '/');
$pattern = "/^.*$pattern.*\$/m";
if (preg_match_all($pattern, $contents, $matches)) {
echo "<pre>Matches were found for $searchfor:
";
echo implode("
", $matches[0]);
?>
Instead of just searching through the one file "file.txt", I want it to search through a whole directory of files to find the string.
Thank you.