I have read the other questions, none have answered nor helped me.
Here is my issue, I have an object/array which contains a property which is also an object/array.
I have successfully accessed similar properties before via:
$variable[propertyObject][property]
However, I have been receiving the error Notice: Undefined index lately.
Here is the code:
$extensionData = $data['Data'];
echo '<p>' . isset($extensionData['Calories']) ? $extensionData['Calories'] : '' . '</p>';
However, that still throws the same error. Even when I check:
isset($extensionData['Calories'])
, it always resolves to 1/True which means the property should exist, so how can the index be undefined?
And when I do a var_dump or print_r of $extensionData
, this is what I get:
Array
(
[Calories] => 295
[WebDesktopImage] => https://clutch-asset-management.s3.amazonaws.com/elevation-burger/IMG_0760-Edit.jpg
[WebMobileImage] => https://clutch-asset-management.s3.amazonaws.com/elevation-burger/IMG_0760-Edit.jpg
[WebDescription] => BLT image
)
(parentheses)
around your ternary operation. It's probably messing things around. – Classroomisset($extensionData['Calories']) var_dump($extensionData['Calories']);
before theecho
statement. – Lynd.
has higher precedence than?:
. – Cold