March 18, 2009

List of directory contents using array in php

Code
<html>
<body>
<?php
$fileHandler = opendir('C:\Documents and Settings');
while (false !== ($file = readdir($fileHandler))) {
$files[] = $file;
}
sort($files);
print_r($files);
closedir($fileHandler);
?>
</body>
</html>


Output
Array ( [0] => . [1] => .. [2] => A [3] => Administrator [4] => All Users [5] => Default User [6] => LocalService [7] => NetworkService [8] => apache2triad )

No comments:

Post a Comment