In the following code $stu is declared an array however PHP reports invalid argument for foreach(). Why?
echo "<table align='center' border='1px'><tr><td>";
echo "<form action='".$_SERVER['PHP_SELF']."' method='POST'>";
$students=array("Jack","John","Ryan");
foreach ($students as $key=>$stu)
{
echo "Please select a grade for $stu:";
echo "<select name='grade'>";
echo "<option>Grade A</option>";
echo "<option>Grade B</option>";
echo "<option>Grade C</option>";
echo "<option>Grade D</option>";
echo "<option>Grade E</option>";
echo "</select><br/>";
}
for ($i=0;$i<count($students);$i++)
{
echo "<input type='hidden' name='stu[]' value='$students[$i]'>";
}
foreach($stu as $arr_contents)
{
echo "$arr_contents";
}
echo "<input type='hidden' name='posted' value='true'>";
echo "<input type='submit' value='Enter'>";
echo "</form>";
echo "</tr></td></table>";
?>
$stuin theforloop so there will be nothing filled in it. What do you want to achieve in the secondforeachloop?