Skip to content

Instantly share code, notes, and snippets.

@FuruholmAnton
Last active February 2, 2016 19:14
Show Gist options
  • Save FuruholmAnton/fdddd857ca48abfb867d to your computer and use it in GitHub Desktop.
Save FuruholmAnton/fdddd857ca48abfb867d to your computer and use it in GitHub Desktop.
<?php
function listFolderFiles($dir){
$foldersAndFiles = scandir($dir);
foreach($foldersAndFiles as $item){
if (!in_array($item,array(".",".."))){ // scandir() adds . and .. to the array
// Write it out if its an image
if (strpos($item, '.jpg') !== false ||
strpos($item, '.png') !== false ||
strpos($item, '.gif') !== false ){
echo $dir."/".$item."<br>";
}
// Write out heading-comment and enter the next folder
if(is_dir($dir.'/'.$item)){
echo "<br># ".$item."<br>";
listFolderFiles($dir.'/'.$item);
}
}
}
}
// The master folder for all images
listFolderFiles('images');
echo "<br># minified<br>";
listFolderFiles('min');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment