Little-known PHP commands: scandir()
By Kai Seidler on Nov 13, 2009
Always messed around with a combo of opendir(), readdir(), and closedir() if you wanted to read the contents of a directory? Since PHP 5 there is a new sheriff in town: scandir():
<?php $files=scandir("/etc/php5"); print_r($files); ?>
Array (  => .  => ..  => apache2  => conf.d )
Okay, you still need to traverse an array, but it's much easier to use than the traditional way.