I have following structure:
$arr = [
'children' => [
'align.php' => [],
'default.php' => [],
'test.php' => [],
'default-2.php' => [],
]
]
Currently I am using
ksort($arr['children'])
and it sorts it like that:
$arr = [
'children' => [
'align.php' => [],
'default-2.php' => [],
'default.php' => [],
'test.php' => [],
]
]
However, I need the array to be in this order:
$arr = [
'children' => [
'align.php' => [],
'default.php' => [],
'default-2.php' => [],
'test.php' => [],
]
]
I've tried the NATURAL_SORT flag, but that didn't work. What other options are there?
You can extract the file names using the pathinfo function, and then compare them in the callback function in the uksort function.
fiddle
A more complex sorting of file names with multiple dots is solved, for example, like this
fiddle