rpflorence
02-08-2008, 04:14 AM
<?
$list = array(); // initialize an array
$showcaseDir = opendir('../showcase/'); // attempt to open directory
while ($f = readdir($showcaseDir)) { // loop the directory
if ($f=='.' or $f=='..' or $f=='.DS_Store') { continue; } // skip this stuff
array_push($list, $f); // slap it into the array
}
closedir($showcaseDir);
foreach($list as $l){
echo '<option value="'.$l.'">'.$l.'</option>';
}
?>
This kicks out what I want (a list of directory names in a <select> box) but it also prints the whole array afterward as just text! What part of that code is causing it to do that?
I only want it to go into the <option> spots.
This is my first attempt with directory fun.
Thanks!
$list = array(); // initialize an array
$showcaseDir = opendir('../showcase/'); // attempt to open directory
while ($f = readdir($showcaseDir)) { // loop the directory
if ($f=='.' or $f=='..' or $f=='.DS_Store') { continue; } // skip this stuff
array_push($list, $f); // slap it into the array
}
closedir($showcaseDir);
foreach($list as $l){
echo '<option value="'.$l.'">'.$l.'</option>';
}
?>
This kicks out what I want (a list of directory names in a <select> box) but it also prints the whole array afterward as just text! What part of that code is causing it to do that?
I only want it to go into the <option> spots.
This is my first attempt with directory fun.
Thanks!