0

So basically I am able to sort the multi-dimensional array using category_a, however what I want is to sort again the multi array based on category_b but I want to retain the sort order of category_a.

Similar with mysql order by (e.g. ORDER BY category_a, category_b)

$data = Array(
    [0] => Array
        (
            [name] => User 1
            [category_a] => ABC
            [category_b] => DEF
            [category_c] => GHI
        )
    [1] => Array
        (
            [name] => User 2
            [category_a] => BCD
            [category_b] => EFG
            [category_c] => HIJ
        )
)

foreach ($dataas $key => $row) {
    $cat_a[$key] = $row['category_a'];
}

array_multisort($cat_a, SORT_DESC, $data);

Thanks in advance!

Paengski
  • 339
  • 2
  • 6
  • 15

0 Answers0