I want to scan the last folder in a directory and display the images in it

时间:2016-02-12 19:53:19

标签: php

So far ive gotten this down but it displays the contents for all the folders not just the last one. Ive tried using end(); on the list but that didnt work.

    function listFolderFiles($dir){
    $ffs = scandir($dir);
    $i = 0;
    $list = array();
    foreach ( $ffs as $ff ){
        if ( $ff != '.' && $ff != '..' ){
            if ( strlen($ff)>=5 ) {

                    $list[] = $ff;
                    //echo dirname($ff) . $ff . "<br/>";
                    echo $dir.'/'.$ff.'<br/>';

            }       
            if( is_dir($dir.'/'.$ff) ) 
                    listFolderFiles ($dir.'/'.$ff);
        }
    }
    return $list;
}

$files = array();
$files = listFolderFiles(dirname(__FILE__));

lets say for instance i have a folder and within it i have folders named as such

  • 02-08-2016
  • 02-09-2016
  • 02-10-2016
  • 02-11-2016
  • 02-12-2016

I want it to always pick the last folder, and display its contents which are images.

0 个答案:

没有答案