note 82271 deleted from function.scandir by felipe

From: Date: Fri, 29 Aug 2008 23:28:26 +0000
Subject: note 82271 deleted from function.scandir by felipe
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-144010@lists.php.net to get a copy of this message
Note Submitter: krom ---- You could also simply remove the first two entries in the returned array, if it is an array and contains more than two entries. (if it contains only two entries, you have an empty directory) Since at least for windows and linux every directory contains '.' and '..', which will be the first two entries in the returned array. Correct me if i'm wrong. $files = scandir($myDir); if (is_array($files) && sizeof($files) > 2) { unset($files[0]); unset($files[1]); // reindex, if needed $files = array_values($files); // work with rest of array // ... } Obviously remove the last two entries, if you sorted it the other way around. Regards, krom

« previous php.notes (#144010) next »