I am coding a simple loop through an associative array in php. Here is my code:
<?php
$height["Peter"]=177;
$height["Laura"]=179;
$height["Adam"]=169;
//echo "Peter is ".$height["Peter"]." cm tall.";
foreach($height as $x => $y) {
//echo $x;
echo $x." is ".$y." cm tall.";
//echo $y;
}
?>
output:
PHP Parse error: syntax error, unexpected '$x' (T_VARIABLE) in /home/ndGQqP/prog.php on line 9
Line 9 starts with the foreach. Could you please help me to find a mistake? Thank you.