note 73061 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 18:58:40 +0000
Subject: note 73061 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126495@lists.php.net to get a copy of this message
Note Submitter: aryel at redtwilight dot com dot br ---- This is a simple function, similar to the PHP5's scandir(), but works for PHP4 aswell. It returns an array with files and directories in it, skipping directories and the '..' and '.' if you choose to. <?php function php4_scandir($dir,$listDirectories=false, $skipDots=true) { $dirArray = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if (($file != "." && $file != "..") || $skipDots == true) { if($listDirectories == false) { if(is_dir($file)) { continue; } } array_push($dirArray,basename($file)); } } closedir($handle); } return $dirArray; } ?>

« previous php.notes (#126495) next »