ok so i am trying to fill a 2d array with random numbers and find the max size in each row. i don't know what is wrong with my code.
here is the code
<html>
<body>
<title>Assign 2</title>
</head>
</body>
<hr/><p/>
<?php
$arr=array();
$max_row=array();
function find_max_row()
{ global $max_row;
global $arr;
for($i=0;$i<10;$i++)
{ $min=0;
for($d=1;$d<10;$d++)
{ $arr[$i][$d]=rand(1,100);
}
}
}
function find_max_row_again()
{ global $max_row;
global $arr;
for($i=0;$i<10;$i++)
{ $min=0;
for($d=1;$d<10;$d++)
{ if($arr[$i][$min]<$arr[$i][$d])
{ $min=$d;
}
}
$max_row[$i]=$arr[$i][$min];
}
}
function fill_array()
{ global $arr;
for($i=0;$i<10;$i++)
{ $arr[$i]=array();
for($d=1;$d<10;$d++)
{ $arr[$i][$d]=rand(1,100);
}
}
}
fill_array();
echo "<table cellpadding=\"4\" border=\"1\" width=\85%\" align\"center\">";
for($i=0;$i<10;$i++)
{ echo "<tr>";
for($d=0;$d<10;$d++)
{ echo $arr[$i][$d];
}
}
echo "</table><p/><p/><p/>\n";
find_max_row_again();
echo "<table cellpadding=\"4\" border=\"1\" align=\"center\">";
for($i=0;$i<10;$i++)
{ echo "<tr>";
for($d=0;$d<10;$d++)
{ echo $arr[$i][$d];
}
}
echo "</table><p/><p/><p/>\n";
find_max_row_again();
echo "<table cellpadding=\"4\" border=\"1\" align=\"center\">";
for($i=o;$i<10;$i++)
{ echo $max_row[$i];
}
echo "</table><p/>\n";
?>
</body>
</html>
please help