Indeed, preg_grep is for using regular expressions on arrays of strings, not files.
(I wonder how drunk they were when they thought of that nameπ )
But this function is quite 'cool' to find the lines of text that contain what you are looking for;
// Load a file into an array
$aLines = file('/path/to/file.txt');
// Find the lines that have 'foo' in them
$aMatches = preg_grep("/foo/", $aLines);
// print the results
foreach($aMatches as $sLine)
{
echo $sLine;
}
Now you can use the 'real' grep to find the names of the files that contain your keywords, and use this function to print the matches in a way that makes sense :-)
Well spotted fLIPIS!