How can apply ksort
to each element of $counts
array? I mean simply call this function on each nested array, not recursively.
bool array_walk(array &$array, callable $funcname [,mixed $userdata = NULL])
I've tried array_walk
passing the flag SORT_NUMERIC
as user data. This gives me a warning:
$counts = array();
$counts['group1'] = array(); // Keys are timestamps but as STRING
$counts['group2'] = array(); // Keys are timestamps but as STRING
// ...
// Array + operator does a key reordering here
$counts['group1'] += $dummyData;
$counts['group2'] += $dummyData;
// .. so sort array by keys
array_walk($counts, 'ksort', SORT_NUMERIC);
Warning: ksort() expects at most 2 parameters, 3 given.
What's the third parameter?
EDIT: genius answer:
foreach($counts as &$group) :
ksort($group, SORT_NUMERIC);
endforeach;