note 28231 deleted from function.readdir by tularis
| From: | tularis@php.net | Date: | Sun, 13 May 2007 19:07:16 +0000 |
| Subject: | note 28231 deleted from function.readdir by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-126557@lists.php.net to get a copy of this message | ||
Note Submitter: nick_vollebergh at hotmail dot com
----
This is a good way to put all your files from a directory in an arry, and echo them on your page.
<?php
$the_array = Array();
$handle = opendir('.');
while (false !== ($file = readdir($handle))) {
if ($file != "." && $file != "..") { /* as descripted below: these
"files" will not be added to the array */
$the_array[] = $file;
}
}
closedir($handle);
foreach ($the_array as $element) {
echo "$element @br /@ \n";
}
?>