Directory listing with DirectoryIterator

Instead of using glob(), You can use more objective way.

The DirectoryIterator class provides a nice interface for viewing the contents of filesystem directories.

$dir = new DirectoryIterator('/');
foreach ($dir as $fileinfo) {
   echo $fileinfo->getFilename() . "\n";
}

see also: php.net DirectoryIterator