note 62232 added to function.readdir

From: Date: Wed, 22 Feb 2006 23:04:24 +0000
Subject: note 62232 added to function.readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-104253@lists.php.net to get a copy of this message
Took cart at kolix dot de's wrapper and changed it into a simple readdir wrapper that does the same, but puts directories first and sorts. Hope it's useful :) function readdirsort($dir) { /* Funktastic readdir wrapper. Puts directories first and sorts. */ static $not_first_run, $last_read_item=0, $items; if (!$not_first_run) { $not_first_run = true; while (false !== ($file = readdir($dir))) { if (is_dir("$file")) $dirs[] = $file; else $files[] = $file; } natcasesort($dirs); natcasesort($files); $items = array_merge($dirs, $files); } if ($items[$last_read_item] == false) return false; else return $items[$last_read_item++]; } ---- Server IP: 84.18.202.180 Probable Submitter: 62.56.39.205 ---- Manual Page -- http://www.php.net/manual/en/function.readdir.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+62232 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+62232&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+62232&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104253) next »