Last active
August 29, 2015 14:00
-
-
Save enijar/11110429 to your computer and use it in GitHub Desktop.
List all images in a directory recursively.
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 | |
function list_all_images($path) | |
{ | |
$array = array(); | |
$finfo = finfo_open(FILEINFO_MIME_TYPE); | |
$files = new RecursiveIteratorIterator( | |
new RecursiveDirectoryIterator($path), | |
RecursiveIteratorIterator::SELF_FIRST | |
); | |
foreach($files as $name => $file) { | |
if(preg_match('/image.*/',finfo_file($finfo, $file))) { | |
array_push($array, $name); | |
} | |
} | |
return $array; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment