Forked from tureki/php-get-last-modified-file-in-folder.php
Created
January 31, 2023 18:06
-
-
Save goesredy/ec168ff8e37face2184931684d630ab7 to your computer and use it in GitHub Desktop.
Revisions
-
tureki created this gist
Feb 20, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ <?php $str_path = '/PATH/'; $cls_rii = new \RecursiveIteratorIterator( new \RecursiveDirectoryIterator( $str_path ), \RecursiveIteratorIterator::CHILD_FIRST ); $ary_files = array(); foreach ( $cls_rii as $str_fullfilename => $cls_spl ) { if($cls_spl->isFile()) { $ary_files[] = $str_fullfilename; } } $ary_files = array_combine( $ary_files, array_map( "filemtime", $ary_files ) ); arsort( $ary_files ); $str_latest_file = key( $ary_files ); echo "file:".$str_latest_file."\n"; echo "time:".$ary_files[key( $ary_files )]; ?>