如何在PHP中获取解码的JSON数据的值 [英] How to get values of decoded JSON data in PHP
本文介绍了如何在PHP中获取解码的JSON数据的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
{"senderDetails":[{"status":"failed","senderid":"0","message":"Kindly upgrade your account to use this service."}]}
以上是我的JSON数据.我使用json_decode()
函数进行解码,但是我不知道如何在PHP中分别回显每个对象的值.
Above is my JSON data. I used json_decode()
function to decode, but I don't know how to echo the values of each object separately in PHP.
推荐答案
例如,如果要打印senderid:
For example, if you want to print the senderid :
<?php
$var = '{"senderDetails":[{"status":"failed","senderid":"0","message":"Kindly upgrade your account to use this service."}]}';
$decoded = json_decode($var);
var_dump($decoded);
echo($decoded->senderDetails[0]->senderid);
?>
在这种类型的计算机上使用 var_dump()很重要变量以了解如何正确访问它们.
It's important to use var_dump() on those kind of variables to understand how to access them properly.
这篇关于如何在PHP中获取解码的JSON数据的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文