实例
列出 images 目录中的文件和目录:
<?php
$dir = "/images/";
// 以升序排序 - 默认
$a = scandir($dir)
;
// 以降序排序
$b = scandir($dir,1)
;
print_r($a);
print_r($b);
?>
结果:
Array ( [0] => . [1] => .. [2] => cat.gif [3] => dog.gif [4] => horse.gif [5] => myimages ) Array ( [0] => myimages [1] => horse.gif [2] => dog.gif [3] => cat.gif [4] => .. [5] => . )