I have previously iterated thru a filesystem and uploaded a large number of files whose filename's matched a string and all the matched strings are in an array.
I am now trying to iterate thru that same file system to output a csv file of all the file's that did NOT get uploaded on the first pass.
// The SPL object is working fine here; problem is in my logic below ...
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path);
foreach($it as $file){
$filename = $file->getFilename();
$uploaded_filenames = ['face', 'arm', 'leg'];
foreach($uploaded_filenames as $up){
if(strpos($filename, $up) !== false {
// do nothing!
}else{
fputcsv($handle, $filename);
}
}
}
Just looking for a more /correct/elegant way of doing this
Thank you Orangepill, that just about worked. The exact syntax:
$in_array = false;
foreach($this->uploaded_filenames as $whatever){
if(strpos($filename, $whatever) !== false){
$in_array = true;
break;
}
}
if(!$in_array) fputcsv($handle, $fullpath);
Thanks again!