Friday, November 13th, 2009
Little-known PHP commands: scandir()
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.