I understand how to delete a specified file using the 'unlink' command in PHP, but what I need to do is to write some code that will take all (10,000+) files in a folder (possibly put them into an array), open them, and then delete ONLY files that contain specific information. (All files in the folder are .txt files containing a list, or array, of numbers. EX: I want to delete any files where 4,5,6,7th slots in the array contained 20,20,100,100 respectively).
Is this a start:
<?php
$directory = '/path/to/files';
if (! is_dir($directory)) {
exit('Invalid diretory path');
}
$files = array();
foreach (scandir($directory) as $file) {
if ('.' === $file) continue;
if ('..' === $file) continue;
$files[] = $file;
}
var_dump($files);
?>