Hi, I am working through a php book, and testing their examples. When i try to run two similar while loops that output the same data, it only displays the first one. I just want to know the logic behind this.
My code is below:
<head>
</head>
<body>
<?
$products = array( "Tires", "Oil", "Spark Plugs" );
$prices = array("Tires"=>100, "Oil"=>10, "Spark Plugs"=>4 );
echo "<table border=1>\n";
for($i=0; $i<3; $i++)
{
echo "<tr><td>$products[$i]</td></tr>\n";
}
echo "</table>\n";
while ($element = each($prices))
{
echo $element[ "0" ];
echo " - ";
echo $element[ "1" ];
echo "<br>";
}
while (list ($product, $price ) = each( $prices ))
echo "$product - $price<br><br>";
?>
</body>