how to sort out folder directory by alphabetically using php please help me to solve this problem and this is not [duplicate] post thanks.
this code is showing like this (sort by time)
- Dog
- Cat
- Orange
- Apple
- Doll
- Fish
- Airplane
- Banana
- Elephant
And i want like this
ABC
- Airplane
- Apple
- Apple
- Banana
- Cat
DEF
- Dog
- Doll
- Elephant
- Fish
php code
<?php
function folderlist(){
$startdir = './';
$ignoredDirectory[] = '.';
$ignoredDirectory[] = '..';
if (is_dir($startdir)){
if ($dh = opendir($startdir)){
while (($folder = readdir($dh)) !== false){
if (!(array_search($folder,$ignoredDirectory) > -1)){
if (filetype($startdir . $folder) == "dir"){
$directorylist[$startdir . $folder]['name'] = $folder;
$directorylist[$startdir . $folder]['path'] = $startdir;
}
}
}
closedir($dh);
}
}
return($directorylist);
}
$folders = folderlist();
sort($folders);
foreach ($folders as $folder){
$path = $folder['path'];
$name = $folder['name'];
echo '<div class="menu">
<h3 class="headerbar"><a href="' .$path .'index2.php?folder=' .$name . '" class="style1"><span class="headertit">' .$name . '</span></a></div>';
}
?>