note 78592 deleted from function.sort by tularis

From: Date: Thu, 18 Oct 2007 14:20:04 +0000
Subject: note 78592 deleted from function.sort by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-131502@lists.php.net to get a copy of this message
Note Submitter: danielnery at gmail dot com Reason: useless ---- I was trying to list a bunch of pictures, but sorting was a trouble... So, after searching throughout php.net and other sites, I compiled the code below. It is simple as I could write it, but it worked really fine. <?php $dir = "your/dir/here/"; //handling the directory if ($handle = opendir($dir)) { while (false !== ($filename = readdir($handle))) { $files[] = $filename; } closedir($handle); } sort($files); $foo = array_slice($files,2); //removing . and .. foreach ($foo as $bar){ echo $bar; // outputs each file name } ?>

« previous php.notes (#131502) next »