How to get file name matches in a directory containing 1 million files
glob It’s slow
File::glob(‘*’)
$files = File::allFiles($path);
$mages=array();
foreach ($files as $file)
{
if ($file->getExtension()==='jpg' or $file->getExtension()==='png' ) {
$images[]=$file->getPath().'/'.$file->getFilename();
}
}
What can be done to make it not so slow?
How do I optimize the search?
You need to sign in to view this answers
Leave feedback about this