note 73836 added to function.readdir

From: Date: Mon, 12 Mar 2007 17:20:40 +0000
Subject: note 73836 added to function.readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-124380@lists.php.net to get a copy of this message
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 ---- Server IP: 194.109.193.76 Probable Submitter: 84.87.26.251 ---- Manual Page -- http://www.php.net/manual/en/function.readdir.php Edit -- https://master.php.net/note/edit/73836 Del: integrated -- https://master.php.net/note/delete/73836/integrated Del: useless -- https://master.php.net/note/delete/73836/useless Del: bad code -- https://master.php.net/note/delete/73836/bad+code Del: spam -- https://master.php.net/note/delete/73836/spam Del: non-english -- https://master.php.net/note/delete/73836/non-english Del: in docs -- https://master.php.net/note/delete/73836/in+docs Del: other reasons-- https://master.php.net/note/delete/73836 Reject -- https://master.php.net/note/reject/73836 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#124380) next »