Answers for "sorting array with mutiple keys php"

PHP
0

php sort multidimensional array by key

function buildSorter($key) {
    return function ($a, $b) use ($key) {
        return strnatcmp($a[$key], $b[$key]);
    };
}

usort($array, buildSorter('key_b'));
Posted by: Guest on June-25-2021

Browse Popular Code Answers by Language