0

I have this array which needs to be re ordered "TH Thickness" lowest to highest. Not sure how I could accomplish this.

Any ideas?

[thickness] => Array
    (
        [0] => Array
            (
                [TH Thickness ID] => 23
                [TH Thickness] => 100
            )

        [1] => Array
            (
                [TH Thickness ID] => 24
                [TH Thickness] => 120
            )

        [2] => Array
            (
                [TH Thickness ID] => 33
                [TH Thickness] => 150
            )

        [3] => Array
            (
                [TH Thickness ID] => 25
                [TH Thickness] => 50
            )

        [4] => Array
            (
                [TH Thickness ID] => 21
                [TH Thickness] => 60
            )

        [5] => Array
            (
                [TH Thickness ID] => 26
                [TH Thickness] => 70
            )

        [6] => Array
            (
                [TH Thickness ID] => 22
                [TH Thickness] => 80
            )

    )
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87
Ben
  • 5,627
  • 9
  • 35
  • 49

1 Answers1

1

PHP >= 5.5.0

array_multisort(array_column($array['thickness'], 'TH Thickness'), SORT_ASC, $array['thickness']);

PHP < 5.5.0 - You can look at the possible duplicates for your question, or:

foreach($array['thickness'] as $k => $v) {
   $sort[$k] = $v['TH Thickness'];
}
array_multisort($sort, SORT_ASC, $array['thickness']);
AbraCadaver
  • 78,200
  • 7
  • 66
  • 87