创建数组后,我正在尝试设置数组键的值。我知道这会,这确实给出了错误:
Notice: Undefined variable: peter in C:\web\apache\htdocs\test\array.php on line 144 Peter is years old.
$age=array("Peter"=>$ageVal);// Has to come first, since it's inside an include file.
$ageVal = 35; //Comes later.
echo "Peter is " . $age['Peter'] . " years old.";
但是有没有办法在不改变顺序的情况下做到这一点?a)首先创建数组 b)稍后设置数组键的值。