I´ve got the following errormessage:
Parse error: syntax error, unexpected T_DOUBLE_ARROW, expecting T_PAAMAYIM_NEKUDOTAYIM in /var/www/createRecipeIng.php on line 60
Don´t know how to handle that, never had before.
Here´s the code:
$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'];
}
Line 60 is the line with the foreach loop. I know that the error must be there because the values of $ings are correct.
How can I manage this?
You need to define the element key just like any other variable.
You declared
keywhen it should be$key.Check the PHP manual for future reference.
Code fix