note 8347 added to readdir

From: Date: Thu, 07 Sep 2000 09:36:19 +0000
Subject: note 8347 added to readdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-4302@lists.php.net to get a copy of this message
The same, but with the link with the filename. $directory is the directory were you begin to list file. 'mydir' in http://www.myhost.com/mydir <?php function list_dir($dir) { $handle=opendir($dir); echo "<ul>"; while ($file = readdir($handle)) { if ($file != '.' && $file != '..') print ("<li><a href=\"".$GLOBALS["path"].$file."\">".$file."</a>"); if (is_dir($file) && $file != '.' && $file != '..') { $toto = $GLOBALS["path"]; $GLOBALS["path"] .= $file."/"; chdir ($file); list_dir("."); $GLOBALS["path"] = $toto; chdir (".."); } } echo "</ul>"; closedir($handle); } $directory = "tommz"; $GLOBALS["path"] = "http://".$HTTP_HOST."/".$directory."/"; list_dir("."); ?> http://www.php.net/manual/fr/function.readdir.php

« previous php.notes (#4302) next »