PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
ekosoftco
Forum Contributor
Posts: 108 Joined: Fri Aug 04, 2006 8:21 pm
Post
by ekosoftco » Wed May 30, 2007 2:52 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed May 30, 2007 2:54 pm
Add logic (checks) that exclude those two.
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed May 30, 2007 3:13 pm
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.
ekosoftco
Forum Contributor
Posts: 108 Joined: Fri Aug 04, 2006 8:21 pm
Post
by ekosoftco » Wed May 30, 2007 4:48 pm
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();
?>
RobertGonzalez
Site Administrator
Posts: 14293 Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA
Post
by RobertGonzalez » Wed May 30, 2007 4:55 pm
I was thinking more along the lines of:
Code: Select all
<?php
if ($ska != '.' && $ska != '..') {
// ...
}
?>