Page 1 of 1
file directory
Posted: Wed May 30, 2007 2:52 pm
by ekosoftco
Code: Select all
<?php
$dir=dir("./$folder/.");
while($filename=$dir->read()) {
$lineArray = explode('$filename', $filename);
$ska = trim($lineArray[0]);
echo "<a href=$ska>";
$skaa = str_replace('.php', '</a><br><img src="../images/line.png" width="141" height="20" /><br>', $ska);
echo "<center>$skaa";
echo "</center>";
}
$dir->close();
?>
now this shows up correctly, i have everything right,except it shows up the root link too, the "." and ".."
so the result is
.
..
file1
file2
file3
but i dont want the "." and ".." there, is there a way to take out just that.
Posted: Wed May 30, 2007 2:54 pm
by feyd
Add logic (checks) that exclude those two.
Posted: Wed May 30, 2007 3:13 pm
by RobertGonzalez
So you are asking if there is a way that if $ska is equal to '.' or $ska id equal to '..' if you can not show it? Yup, it can be done.

Posted: Wed May 30, 2007 4:48 pm
by ekosoftco
i guess this will work :/
Code: Select all
<?php
$dir=dir("./$folder/.");
while($filename=$dir->read()) {
$lineArray = explode('$filename', $filename);
$ska = trim($lineArray[0]);
echo "<a href=$ska>";
$skaa = str_replace('.php', '</a><br><img src="../images/line.png" width="141" height="20" /><br>', $ska);
$skdone = str_replace('..', ' ', $skaa);
echo "<center>$skdone";
echo "</center>";
}
$dir->close();
?>
Posted: Wed May 30, 2007 4:55 pm
by RobertGonzalez
I was thinking more along the lines of:
Code: Select all
<?php
if ($ska != '.' && $ska != '..') {
// ...
}
?>