I have a problem finding out the highest value of one row of a multidimensional array.
The array is like:
$array[$days][events]
I am looping from 1 to 31 (the days of a month) to receive the number of events on the day $days.
For the next step I need to know the highest index (value) of the events row. (Can be any number from 0 to 1293xxxx)
I have already tried count, but it just returns the number of events, not the last event index.
First make an array which contain each day's higher value with max()
, then use max()
on this new array and you're ok
$cnt = 0;
$tab = array();
while (isset($array[$cnt]))
{
$tab[] = max($array[$cnt]);
cnt++;
}
$maxvalue = max($tab);
EDIT: sorry i didn't understand, what i wrote will take the global hightest.
You just need to use max()
on the table you want. Good luck
Try this
for ($i = 0; $i <= 31; $i++) {
ksort($array[$i], SORT_NUMERIC);
end($array[$i]);
$events[$i] = key($events);
}