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, Link to comment https://forums.phpfreaks.com/topic/164326-solved-read-dir/ 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>'; } Link to comment https://forums.phpfreaks.com/topic/164326-solved-read-dir/#findComment-866859 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 />'; } }?> Link to comment https://forums.phpfreaks.com/topic/164326-solved-read-dir/#findComment-867027 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.