toxictoad Posted December 7, 2008 Share Posted December 7, 2008 Hey all, I want to use this script <?php $dir = "http://mysite.com/files/uploads/"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"; } closedir($dh); } } if ($handle = opendir('.')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { echo "$file\n"; } } closedir($handle); } ?> That works great but each file runs after the other and I'd prefer it if after each file there was a <br /> but I haven't a clue where to start. Also I've seen on php.net ways to restrict what files are shown but again I don't know enough to modify what I have to do this. I'd like to hide .php files. Can anyone help with this? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/135975-solved-folder-view-works-but-can-the-output-be-formatted/ Share on other sites More sharing options...
awpti Posted December 7, 2008 Share Posted December 7, 2008 Replace the \n with <br /> or just add a <br /> after or before the \n Quote Link to comment https://forums.phpfreaks.com/topic/135975-solved-folder-view-works-but-can-the-output-be-formatted/#findComment-708820 Share on other sites More sharing options...
premiso Posted December 7, 2008 Share Posted December 7, 2008 nl2br luckily there is that nice function to do it for you. Quote Link to comment https://forums.phpfreaks.com/topic/135975-solved-folder-view-works-but-can-the-output-be-formatted/#findComment-708827 Share on other sites More sharing options...
toxictoad Posted December 7, 2008 Author Share Posted December 7, 2008 any chance of an example? because I've added the <br /> before and after the /n in quotes and out of quotes. I've added the nl2br after the echo also with and without the <br /> and with and without the /n but I'm just not seeing what I need to do? but I'm getting errors Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /home/mysite/public_html/files/uploads/index.php on line 8 Parse error: syntax error, unexpected '<' in /home/mysite/public_html/files/uploads/index.php on line 8 Parse error: syntax error, unexpected '"', expecting ',' or ';' in /home/mysite/public_html/files/uploads/index.php on line 8 Thanks... Quote Link to comment https://forums.phpfreaks.com/topic/135975-solved-folder-view-works-but-can-the-output-be-formatted/#findComment-708870 Share on other sites More sharing options...
toxictoad Posted December 8, 2008 Author Share Posted December 8, 2008 Also tried replacing the "/n" with "<br />" and that doesn't work either? Quote Link to comment https://forums.phpfreaks.com/topic/135975-solved-folder-view-works-but-can-the-output-be-formatted/#findComment-708942 Share on other sites More sharing options...
toxictoad Posted December 8, 2008 Author Share Posted December 8, 2008 persitance and trying every possibility got it... Quote Link to comment https://forums.phpfreaks.com/topic/135975-solved-folder-view-works-but-can-the-output-be-formatted/#findComment-708952 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.