我收到了以下错误消息:
Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting T_PAAMAYIM_NEKUDOTAYIM in /var/www/createRecipeIng.php on line 60
不知道如何处理,从未有过。
这是代码:
$ings = array();
$ings = json_decode($incr_arr, true);
print_r($ings);
$reid = 5;
foreach ($ings['Data']['Recipes']['Recipe_' . $reid] as key => $shIng){
echo $shIng['NAME'];
}
第60行是foreach循环的行。我知道错误必须存在,因为$ ings的值是正确的。
我该如何管理?
答案 0 :(得分:0)
您需要像任何其他变量一样定义元素键。
您宣布key
时应该$key
。
检查PHP manual以供将来参考。
代码修复
foreach ($ings['Data']['Recipes']['Recipe_' . $reid] as $key => $shIng){
echo $shIng['NAME'];
}