Show all files directories alphabetically with PHP, Is that possible? I need to list the files of a directory on my webpage. How do i do it? Please help me with the coding... I'm new to PHP... Thanks in advance...
Show all files directories alphabetically with PHP, Is that possible? I need to list the files of a directory on my webpage. How do i do it? Please help me with the coding... I'm new to PHP... Thanks in advance...
Well you must be clear with the basics first. I'm not sure but scandir function will do the work for you... All the best! If any problem, do post back!
Can you please help me with a sample code? May be i would be able to manipulate it with what i require.. Please help the noob...
Here is a sample code :
Code:<?php $dir = "/tmp"; $dh = opendir($dir); while (false !== ($filename = readdir($dh))) { $files[] = $filename; } sort($files); print_r($files); rsort($files); print_r($files); ?>
One more sample code :
Code:<?php $dir = '/tmp'; $files1 = scandir($dir); $files2 = scandir($dir, 1); print_r($files1); print_r($files2); ?>
Bookmarks