Reading Json with PHP

Asked

Viewed 71 times

0

Guys, I have a question in reading Json with PHP.

This is the Json:

{"message":"Oi Gente","report":[{"0":[{"port":"gsm-2.3","phonenumber":"00000000000","time":"1970-01-08 10:00:26","result":"fail"}]}]}, 

but I can’t display your values.

Thanks in advance!

1 answer

1


Do it like this:

$json = '{"message":"Oi Gente","report":[{"0":[{"port":"gsm-2.3","phonenumber":"00000000000","time":"1970-01-08 10:00:26","result":"fail"}]}]}';
$json_dec = json_decode($json, true);

Then if you want for example message:

echo $json_dec['message'];

DEMONSTRATION

If you want to take time in report:

echo $json_dec['report'][0][0][0]['time'];

DEMONSTRATION

Browser other questions tagged

You are not signed in. Login or sign up in order to post.