I need to sort this array by the subsubkey "description" ascending. I tried a few methods like usort, ksort, subval_sort but none of these work (I guess the main problem is that these are strings, always)
Any help is appreciated
array(77) {
[0]=>
array(3) {
["name"]=>
string(17) "abcd"
["description"]=>
string(15) "Delete XY"
["level"]=>
int(1)
}
[1]=>
array(3) {
["name"]=>
string(13) "fgfgdgfd"
["description"]=>
string(18) "Uploader XY"
["level"]=>
int(1)
}
[2]=>
array(3) {
["name"]=>
string(15) "sdfdsfsdfs"
["description"]=>
string(20) "Download abc"
["level"]=>
int(0)
}
}
usort($array, function ($a, $b) {
return strcasecmp($a['description'], $b['description']); //compare two strings ignoring case
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With