Skip to content

Instantly share code, notes, and snippets.

@anytizer
Created November 16, 2013 06:05
Show Gist options
  • Save anytizer/7496547 to your computer and use it in GitHub Desktop.
Save anytizer/7496547 to your computer and use it in GitHub Desktop.
finder
<?php
$find = preg_quote('search-term-what-to-find');
$dir='/home/user/public_html';
chdir($dir);
$files=array();
$files[] = 'file1.php';
$files[] = 'file2.php';
$files[] = 'path1/file3.php';
$files[] = 'path2/file4.php';
$files[] = 'path3/path4/file4.php';
$found=array();
foreach($files as $f => $file)
{
$lines = file($file, FILE_IGNORE_NEW_LINES);
foreach($lines as $l => $line)
{
if(preg_match("/{$find}/is", $line))
{
$found[$file][$l]=$line;
}
}
}
print_r($found);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment