php - Resorting array by lowest to highest -
this question has answer here:
- sort array of objects object fields 12 answers
- sort php multidimensional array sub-value [duplicate] 3 answers
i have array needs re ordered "th thickness" lowest highest. not sure how 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 ) )
php >= 5.5.0
array_multisort(array_column($array['thickness'], 'th thickness'), sort_asc, $array['thickness']); php < 5.5.0 - can @ possible duplicates question, or:
foreach($array['thickness'] $k => $v) { $sort[$k] = $v['th thickness']; } array_multisort($sort, sort_asc, $array['thickness']);
Comments
Post a Comment