Reputation: 5746
I want to get all Folders name. I'm using following codes for that. In main Folder some other files also there. I want to sort the folders name in 'ASC' order.
I can't do by following functions,
<?php
$dirs = array_filter(glob('*'), 'is_dir');
sort($dirs); //used asort() and array_multisort()
print_r($dirs);
?>
It's giving priority to CAPS Letters
I'm getting, Arranging first which folder name starting with CAPS. After that others...
Help me, Thanks...
Upvotes: 0
Views: 414
Reputation: 522135
Note: It's giving priority to CAPS Letters
If that means you want to sort case-insensitively, then you need to set the appropriate flag:
sort($dirs, SORT_FLAG_CASE);
Or use another sorting function:
natcasesort($dirs);
Or use manual comparison with a case-insensitive function:
usort($dirs, 'strcasecmp');
See the comparison of array sorting functions and their relevant individual manual pages.
Upvotes: 3