note 36211 added to function.scandir

From: Date: Wed, 01 Oct 2003 08:05:00 +0000
Subject: note 36211 added to function.scandir
Groups: php.notes 
Request: Send a blank email to php-notes+get-57520@lists.php.net to get a copy of this message
...and with some extra lines you can avoid "." and ".." on the one hand and list only files with the extension $ext on the other hand function scandir($dirstr, $ext){ $files = array(); $fh = opendir($dirstr); while (false !== ($filename = readdir ($fh))){ if (ereg("$ext", $filename, $regs)){ array_push($files, $filename); } } closedir($fh); return $files; } ---- Manual Page -- http://www.php.net/manual/en/function.scandir.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+36211 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+36211&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+36211&report=yes

« previous php.notes (#57520) next »