View Single Post
Old 01-21-2009, 06:49 PM   #2 (permalink)
Wildhoney
La Vida es Sueño
Advanced Programmer Top Contributor 
 
Wildhoney's Avatar
 
Join Date: Sep 2007
Location: Oldham
Posts: 2,280
Thanks: 90
Wildhoney is on a distinguished road
Default

The easiest, and quite possibly the best way, would be to use the glob function. Please have a read of this article. Once you have that, you simply array_reverse the array, and that gives you them in reverse order. Please take a look at the following code; you would want the descending function:

php Code:
function TalkPHP_Dir_Display_Asc($szGlobExpression)
{
    return glob($szGlobExpression, GLOB_ONLYDIR);
}

function TalkPHP_Dir_Display_Desc($szGlobExpression)
{
    $aDirs = glob($szGlobExpression, GLOB_ONLYDIR);
    return array_reverse($aDirs);
}

$aDirs = TalkPHP_Dir_Display_Desc('./*');
$aDirs = array_map('basename', $aDirs);
echo 'Directories: ' . implode(', ', $aDirs);
__________________
The man who comes back through the Door in the Wall will never be quite the same as the man who went out.
Send a message via AIM to Wildhoney Send a message via MSN to Wildhoney Send a message via Yahoo to Wildhoney
Wildhoney is offline  
Reply With Quote