­
­
Sort Multi-dimensional Array by Value – RM Web Lab

Sort Multi-dimensional Array by Value

We can sort multi dimensional array in php easily by any of it’s value. below are simple example I use in my code and it works great!

function woo_prod_label_array_sort_by_column(&$arr, $col, $dir = SORT_ASC) {
$sort_col = array();
foreach ($arr as $key=> $row) {
$sort_col[$key] = $row[$col];
}
array_multisort($sort_col, $dir, $arr);
}

Leave a Reply

Your email address will not be published. Required fields are marked *