JSON to MySQL using PHP - second level JSON results

Hi,

This is my PHP for first-level PHP:

$name = $data[‘name’];

The problem is I cannot access second-level json results using PHP!

I tried:

$date = $data[‘forecast’][‘date’];

Any ideas why the second-level is not working?

Matt.

Maybe because of malformed JSON?

Scott

I am using $data = json_decode($jsondata, true); to access the json - is this correct?

The first level data is coming through fine - how could the second level not be working?

do var_dump($data) so you know what you’re working with instead of blindly guessing around.

did that just now. The output mentions at the start of the second level “[0] Array[34]” do i need to do something about that?

Please share the full code here

Sorted now - just needed a [0] in the middle.

But do you understand why that worked? I had a similar issue a while ago.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.