Folks,
This from w3schools works
[code]
<!DOCTYPE html>
<html>
<body>
<?php
$age = array(“Peter”=>”35”, “Ben”=>”37”, “Joe”=>”43”);
asort($age);
foreach($age as $x => $x_value) {
echo “Key=” . $x . “, Value=” . $x_value;
echo “<br>”;
}
?>
</body>
</html>
Now change the $x to $y and $x_value to $value.
And you get error! Why ?
[code]
<!DOCTYPE html>
<html>
<body>
<?php
$age = array(“Peter”=>”35”, “Ben”=>”37”, “Joe”=>”43”);
asort($age);
foreach($age as $y => $value) {
echo “Key=” . $y . “, Value=” . $value;
echo “<br>”;
}
?>
</body>
</html>
Try changing code here and see for yourself.
PHP Parse error: syntax error, unexpected ‘”Key=”‘ (T_CONSTANT_ENCAPSED_STRING) in /home/tXHEDx/prog.php on line 10
On my localhost, I got error a few times but can’t reproduce anymore and so gave you error from w3schools as error over there always reproducible.