note 78592 added to function.sort
| From: | danielnery at gmail dot com | Date: | Thu, 18 Oct 2007 13:17:37 +0000 |
| Subject: | note 78592 added to function.sort | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-131493@lists.php.net to get a copy of this message | ||
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
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 201.81.210.99
----
Manual Page -- http://www.php.net/manual/en/function.sort.php
Edit -- https://master.php.net/note/edit/78592
Del: integrated -- https://master.php.net/note/delete/78592/integrated
Del: useless -- https://master.php.net/note/delete/78592/useless
Del: bad code -- https://master.php.net/note/delete/78592/bad+code
Del: spam -- https://master.php.net/note/delete/78592/spam
Del: non-english -- https://master.php.net/note/delete/78592/non-english
Del: in docs -- https://master.php.net/note/delete/78592/in+docs
Del: other reasons-- https://master.php.net/note/delete/78592
Reject -- https://master.php.net/note/reject/78592
Search -- https://master.php.net/manage/user-notes.php