PHP: Problem with reading Files

iDan

New Member
i wonder what i'm doing wrong! i want to read a folder and run through the existing files, checking if they are either images or textfiles.if there are textfiles they should be put into a div, if there are images the should be output as an image.\[code\]<?php$path = 'thumbs';if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { $ext = pathinfo($file, PATHINFO_EXTENSION); if ($ext == "jpg" || $ext == "jpeg" || $ext == "gif" || $ext == "png") { print "<img class='thumb' src='http://stackoverflow.com/questions/2945515/$path/$file'/>"; } else if ($ext == "txt" || $ext == "rtf") { //read text $lines = file_get_contents($file); $lines = str_replace("\n","<br/>",$lines); print "<div class='text'>" . $lines . "</div>"; //read text } } closedir($handle);}?>\[/code\]there seems to be a problem i can't find, because ALL IMAGES get put out, however only ONE of a few textfiles gets printed.Any ideas why it only prints out one textfile???thank you for your help!
 
Top