mcubedma Posted May 2, 2008 Share Posted May 2, 2008 Hello. I've used this code snippet to list directory contents, but it lists the contents in a line without blanks. For example, List of files: Autumn Leaves.jpgCreek.jpgDesert Landscape.jpgphpshow.phpindex.phpfilelist.php I'd like to have a line break between file names. Can anyone help me with this? <?php if ($handle = opendir(' . ')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { $thelist .= '<a href="'.$file.'">'.$file.'</a>'; } } closedir($handle); } ?> <P>List of files:</p> <P><?=$thelist?></p> Link to comment https://forums.phpfreaks.com/topic/103909-solved-code-snippet-to-list-directory-contents-need-help-displaying-data/ Share on other sites More sharing options...
hitman6003 Posted May 2, 2008 Share Posted May 2, 2008 add a "<br />" at the end of each file link... $thelist .= '<a href="'.$file.'">'.$file.'</a><br />'; Link to comment https://forums.phpfreaks.com/topic/103909-solved-code-snippet-to-list-directory-contents-need-help-displaying-data/#findComment-532147 Share on other sites More sharing options...
mcubedma Posted May 2, 2008 Author Share Posted May 2, 2008 Great. That worked perfectly. Thank you very much. Link to comment https://forums.phpfreaks.com/topic/103909-solved-code-snippet-to-list-directory-contents-need-help-displaying-data/#findComment-532158 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.