A JM Posted July 1, 2009 Share Posted July 1, 2009 How can I eliminate the root paths from being read using thedir() function? <?php $path = "../claims/" . $row_rstocdetail['maxclaimnum'] . "/"; $dir = dir($path); while($file = $dir->dir()) { echo '<a href="' . $file . '">' . $file . '</a><BR>'; }?> The files that come out are as follows: . .. myfilename1.txt myfilename2.txt ... etc. how can I eleiminate the first 2 items and just list the filenames? myfilename1.txt myfilename2.txt ... etc. Thanks. A JM, Quote Link to comment Share on other sites More sharing options...
Alex Posted July 1, 2009 Share Posted July 1, 2009 while($file = $dir->dir()) { if($file != '.' && $file != '..') echo '<a href="' . $file . '">' . $file . '</a><BR>'; } Quote Link to comment Share on other sites More sharing options...
A JM Posted July 1, 2009 Author Share Posted July 1, 2009 Thanks, I was getting close but couldn't get it.. :-\ <?php $path = "../claims/" . $_GET['ID'] . "/"; $dir = dir($path); while($file = $dir->read()) { if($file != '.') && ($file != '..') { echo '<a href="' . $path . $file . '">' . $file . '</a><br />'; } }?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.