note 73836 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 18:58:30 +0000
Subject: note 73836 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126493@lists.php.net to get a copy of this message
Note Submitter: ExploWare ---- I'd say there is one thing left to do, you should use is_dir() with the path which is given in the function $dir like this: <?php function php4_scandir($dir,$listDirectories=false, $skipDots=true) { $dirArray = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." || $skipDots == false) { #added the $dir. in this line if($listDirectories == false && is_dir($dir.$file)) { continue; } array_push($dirArray,basename($file)); } } closedir($handle); } return $dirArray; } #USE A TRAILING SLASH AT THE $dir VARIABLE print_r(php4_scandir('/dir/',true)); ?> maybe the basename() is also obsolete, but it doesn't make it work the wrong way

« previous php.notes (#126493) next »