note 82271 added to function.scandir

From: Date: Thu, 03 Apr 2008 15:37:33 +0000
Subject: note 82271 added to function.scandir
Groups: php.notes 
Request: Send a blank email to php-notes+get-137893@lists.php.net to get a copy of this message
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 ---- Server IP: 212.124.37.9 Probable Submitter: 83.236.176.115 ---- Manual Page -- http://www.php.net/manual/en/function.scandir.php Edit -- https://master.php.net/note/edit/82271 Del: integrated -- https://master.php.net/note/delete/82271/integrated Del: useless -- https://master.php.net/note/delete/82271/useless Del: bad code -- https://master.php.net/note/delete/82271/bad+code Del: spam -- https://master.php.net/note/delete/82271/spam Del: non-english -- https://master.php.net/note/delete/82271/non-english Del: in docs -- https://master.php.net/note/delete/82271/in+docs Del: other reasons-- https://master.php.net/note/delete/82271 Reject -- https://master.php.net/note/reject/82271 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#137893) next »