Forum Moderators: coopster
.
..
My code:
<?php
$handle = opendir('banners');
while ($file = readdir($handle)) {
$files[] = $file;
foreach ($files as $v) {
echo "{$v}<BR>";
}
}
closedir($handle);
?> I also tried this:
<?php
$handle = opendir('banners');
while ($file = readdir($handle)) {
if ($file!= "." && $file!= "..") {
$files[] = $file;
foreach ($files as $v) {
echo "{$v}<BR>";
}
}
}
closedir($handle);
?> And it does get rid of the dots, but now I get the files several times (some duplicates).
Does anyone know hoe to solve this?
Thanks in dvance,
Stefan
foreach([url=http://us2.php.net/manual/en/function.glob.php]glob[/url]("*") as $file) {
echo $file.'<br />';
}
Good luck!
<?
function dirTree($dir) {
$d = dir($dir);
while (false!== ($entry = $d->read())) {
if($entry!= '.' && $entry!= '..' && is_dir($dir.$entry))
$arDir[$entry] = dirTree($dir.$entry.'/');
}
$d->close();
return $arDir;
}
function printTree($array, $level=0) {
foreach($array as $key => $value) {
$key = str_replace("_", " ", "$key");
echo "· $key";
echo "<br>";
if(is_array($value))
printTree($value, $level+1);
}
}
?>