RE: [PHP] fopen and sort by date modified

From: Date: Wed, 14 Aug 2002 15:04:10 +0000
Subject: RE: [PHP] fopen and sort by date modified
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112543@lists.php.net to get a copy of this message
sweet , damn filemtime this was hiding from me :) -----Original Message----- From: Bas Jobsen [mailto:bas@startpunt.cc] Sent: Wednesday, August 14, 2002 8:48 PM To: electroteque; php-general@lists.php.net Subject: Re: [PHP] fopen and sort by date modified Op woensdag 14 augustus 2002 13:04, schreef electroteque: > hi there i was wondering how i could fopen a directory and then sort the > files by date modified is there a way ? <?php // Note that !== did not exist until 4.0.0-RC2 $dir='/home'; if ($handle = opendir($dir)) { echo "Directory handle: $handle\n"; $lasttime=0; $temp=array(); while (false !== ($file = readdir($handle))) { echo $file; if(is_file($file))$temp[$file]=filemtime($file); } } asort($temp,SORT_NUMERIC); reset($temp); while(list($k,$v)=each($temp)) echo $k.':'.date('r',$v)."\n"; ?>

« previous php.general (#112543) next »