I have an base array
$base =array(
"A1" =array();
"A2" =array();
"A3" =array();
"A4" =array();
);
and array of condition will use to sort
$condition = array("A1" => "SORT_ASC",
"A4" => 'SORT_ASC',
"A3" => 'SORT_DESC'
);
I tried create a function like this to return a array_multi_sort
function sort_by_condition($condition) {
return array_multisort(
$base['A1'], SORT_ASC, SORT_STRING,
$base['A4'], SORT_ASC,SORT_NUMERIC,
$base['A3'], SORT_DESC,SORT_NUMERIC,
$base['A2'],//default
);
}
But I dont know how can I return something like this?
You may need to give the proper array keys to array multisort:
This is from the manual but I assume your example would become more like this:
I realize you have probably read it a few times but see the examples in the manual and try making it work outside the function first. Good-luck! 🙂