Created
August 13, 2020 22:11
-
-
Save alpha1125/c0935e9417822a90d6f17592d6a04c50 to your computer and use it in GitHub Desktop.
scrap files from a subdirectories, for emails, and echo them out as a CSV.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$folders = glob("*", GLOB_ONLYDIR); | |
$emailPattern = "/[A-z0-9._%+-]+@[A-z0-9.-]+\.[A-z]{2,}/"; | |
foreach ($folders as $folder) { | |
$files = glob("$folder/*.html"); | |
foreach ($files as $file) { | |
$contents = file_get_contents($file); | |
echo "$folder,"; | |
if (preg_match($emailPattern, $contents, $matches)) { | |
echo "$matches[0]"; | |
}; | |
echo PHP_EOL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment