note 60939 deleted from function.readdir by tularis

From: Date: Sun, 13 May 2007 19:01:46 +0000
Subject: note 60939 deleted from function.readdir by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-126518@lists.php.net to get a copy of this message
Note Submitter: larry11 at onegentleman dot biz ---- After hours of work I found an error in the sort routine sumitted. The correction lies in the fact you need $path.$file to diffirentiate from [dir] or [file] in the routines $path = "music/Holly Dunn/"; $dh = opendir($path); while (false !== ($file=readdir($dh))) { if (substr($file,0,1)!=".") { if (is_dir($path.$file)) $dirs[]=$file.'/'; else $files[]=$file; } } @closedir($dh); if ($files) natcasesort($files); if ($dirs) natcasesort($dirs); $files=array_merge($dirs,$files); foreach ($files as $file) echo "<a href=$file>$file</a><br />"; ?>

« previous php.notes (#126518) next »