Is there such a function in PHP that does grep -f filename in unix/linux systems.
If there is none, what PHP functions/tools would help in creating a customised method/function for this. Thanks!
Is there such a function in PHP that does grep -f filename in unix/linux
Share
Actually IMHO, I’d say it’s the following:
See
preg_grepDocs andfileDocs.If you need to do that (recursively) over a set of files, there is also
globandforeachor the (Recursive)DirectoryIteratoror theGlobIteratorDocs and not to forget theRegexIteratorDocs.Example with SplFileObject and RegexIterator:
Output (all lines of
$filecontaining $pattern):Demo: https://eval.in/208699