Looking at files within a folder...

file2.txt
log2.log
file1.txt
.
..
log1.log

 

<?php
    $handle = opendir('./sub');
    while(false !== ($file = readdir($handle))){
        echo "$file<br />";
    }
    closedir($handle);
?>