Readdir(), dot's
Moderator: General Moderators
Readdir(), dot's
When I use readdir() with loops I always get this enoying dot's on the top. Think everyone know what i mean? Anyway to remove this dot's?
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
- hob_goblin
- Forum Regular
- Posts: 978
- Joined: Sun Apr 28, 2002 9:53 pm
- Contact:
I tried using what volvo did, but it didn't go to well
. I understand what he did, and tried doing this my self by making an if() that checks if any of the filenames are . or .., but I didn't get it to remove the dot's.
Code: Select all
<?php
$dirnavn = "../produkter";
$opendir = opendir( $dirnavn );
while( $file = readdir( $opendir ) )
{
print('<input type="radio" name="'."slett".'" value="'."$file".'">'."$to_start$file$to_end<br>\n");
}
?>Code: Select all
<?php
$dirnavn = "../produkter";
$opendir = opendir( $dirnavn );
while( $file = readdir( $opendir ) )
{
if($file != "." || $file != "..") {
echo "<input type="radio" name="slett" value="".$file."">".$to_start.$file.$to_end."<br>\n";
}
}
?>Code: Select all
<?php
$dirnavn = "../produkter";
$opendir = opendir( $dirnavn );
while (($file = readdir($opendir)) !== false) {
if ($file != "." && $file != "..") {
echo "<input type='radio' name='slett' value='$file'>$to_start$file$to_end<br>\n";
}
}
closedir($opendir);