06.
Working with Files, JSON and Booleans
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
Whoops, an error! Please, try again later.
6 Comments
Hi, in the first challenge example you wrote:
json_encode('lions', 'tigers', 'bears');instead of
json_encode(['lions', 'tigers', 'bears']);Hey Najah M.
Great catch! Thanks for your report! It will be fixed soon!
Cheers!
^_^
how do I show: "weight": 8,????
echo $json->weight.
Hey Teo,
It depends! Most probably you should iterate over array, as we have an array of pets. So if you decode JSON into the array of objects - do next:
But if you pass "true" for the second argument, you will get array of arrays instead of array of objects, so do it as:
You can always dump variable first to ensure what data it consists, and then you'll be able to get data correctly:
Cheers!
`Json` responses looks a really very nice and handy with JSONView Chrome plugin, thanks!
"Houston: no signs of life"
Start the conversation!