Answers for "order by array like sql php"

PHP
0

order by array like sql php

$id_group = array();
$id_group_pos = array();

// Obtain a list of columns
foreach ($product_list as $key => $row) {
  $id_group[$key]  = $row['id_group'];
  $id_group_pos[$key] = $row['id_group_pos'];
}

// Sort the product_list with id_group ascending then id_group_pos ascending
array_multisort($id_group, SORT_ASC, $id_group_pos, SORT_ASC, $product_list);
Posted by: Guest on December-08-2020

Browse Popular Code Answers by Language