04-08-2009, 05:01 PM
|
#1 (permalink)
|
|
The Acquainted
Join Date: May 2008
Location: Québec
Posts: 104
Thanks: 10
|
Array diplaying Folder on top ?
Good day,
here I'm working on an array which read a directory and list the files and folders recursively.
I'm trying to display in bold , and on top of all files, all the folders.
PHP Code:
<?php
$directory = "Art/"; function dirList ($directory) {
// create an array to hold directory list $results = array();
// create a handler for the directory $handler = opendir($directory);
// keep going until all files in directory have been read while ($file = readdir($handler)) {
// if $file isn't this directory or its parent, // add it to the results array if ($file != '.' && $file != '..') // If file is directory, mark it in bold. if (is_dir($file)){ echo "<b>"; echo $file; echo "</b><br/>"; // Else not styled }else{ echo $file; echo "<br/>"; } }
// Here probably should be my code for sorting the folder on top of the files.
// tidy up: close the handler closedir($handler);
// done! return $results;
}
dirList($directory);
?>
Thanks !
__________________
That's why we are not alone on earth... let's build !
|
|
|
|