PHP 27
Sort a Multi-dimensional Array by Value By micha on 11th December 2022 07:29:14 PM
  1. function array_sort_by_column(&$arr, $col, $dir = SORT_ASC) {
  2.     $sort_col = array();
  3.     foreach ($arr as $key => $row) {
  4.         $sort_col[$key] = $row[$col];
  5.     }
  6.  
  7.     array_multisort($sort_col, $dir, $arr);
  8. }
  9.  
  10. array_sort_by_column($array, 'order');

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.