note 66327 deleted from function.scandir by felipe
| From: | felipe@php.net | Date: | Fri, 29 Aug 2008 23:24:43 +0000 |
| Subject: | note 66327 deleted from function.scandir by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-143999@lists.php.net to get a copy of this message | ||
Note Submitter: greg at sasses dot net
----
A minor revision to elbekko at gmail dot com <PHP5 scandir function. The arsort should be rsort.
Here is the complete function with the correction:
<?php
if(!function_exists('scandir')) {
function scandir($dir, $sortorder = 0) {
if(is_dir($dir)) {
$dirlist = opendir($dir);
while( ($file = readdir($dirlist)) !== false) {
if(!is_dir($file)) {
$files[] = $file;
}
}
($sortorder == 0) ? asort($files) : rsort($files); // arsort was replaced with rsort
return $files;
} else {
return FALSE;
break;
}
}
}
?>