Hi,
I have a multidimensional array like
0 1 2 3 4
2 1.5 0 2.3
3 4 5 6
1 2 3 4
i need to find max of each row of this array and retreive corresponding index of the array where this max value is obtained
I found the max value but could not fetch the index. how could i fetch column index of particular row where this max value is found. Could you please advice.
i have posted the code for finding max.
for($row=0;$row<count($my_array);$row++)
{
$max=$my_array[$row][0];
for($col=1;$col<count($my_array[$row]);$col++)
{
if ($my_array[$row][$col] > $max )
{
$max= $my_array[$row][$col];
}
}
echo $max."<br>" //this gives max value
//upto max is correct but i am stuck on index fetching
while($element=each($my_array[$row])
{
if($element['value']==$max)
{
echo $element['key'];
}
}