PHP reports invalid argument for foreach(). Why?
<p>In the following code $stu is declared an array however PHP reports invalid argument for foreach(). Why?</p>

<p><pre><code>


<pre><code>echo "&lt;table align='center' border='1px'&gt;&lt;tr&gt;&lt;td&gt;";
echo "&lt;form action='".$_SERVER['PHP_SELF']."' method='POST'&gt;";
$students=array("Jack","John","Ryan");
foreach ($students as $key=&gt;$stu)
 {
echo "Please select a grade for $stu:";
echo "&lt;select name='grade'&gt;";
echo "&lt;option&gt;Grade A&lt;/option&gt;";
echo "&lt;option&gt;Grade B&lt;/option&gt;";
echo "&lt;option&gt;Grade C&lt;/option&gt;";
echo "&lt;option&gt;Grade D&lt;/option&gt;";
echo "&lt;option&gt;Grade E&lt;/option&gt;";
echo "&lt;/select&gt;&lt;br/&gt;";
  }
for ($i=0;$i&lt;count($students);$i++)
{
    echo "&lt;input type='hidden' name='stu[]' value='$students[$i]'&gt;";
}

foreach($stu as $arr_contents)
{
echo "$arr_contents";
}

echo "&lt;input type='hidden' name='posted' value='true'&gt;";
echo "&lt;input type='submit' value='Enter'&gt;";
echo "&lt;/form&gt;";
echo "&lt;/tr&gt;&lt;/td&gt;&lt;/table&gt;";
?&gt;
</code></pre>

<p></pre></code></p>
