本文介绍了访问特定的JSON值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我目前有一个变量$ return,其中包含JSON编码的数据,其输出为:
I currently have a variable $return which contains JSON-encoded data, which prints out as:
({0:{data:[[0, null], [1, null], [2, null], [3, null], [4, null], [5, null], [6, null], [7, null], [8, null], [9, null], [10, null], [11, null], [12, null], [13, null], [14, null], [15, null], [16, null], [17, null], [18, null], [19, null], [20, null], [21, null], [22, null], [23, null]], label:null, count:null},等(太多,无法复制和粘贴).基本上,我想做的是找出data:[0,null]的值是否为null,然后根据结果创建一个if else语句.如果为空,则需要显示一条消息无可用数据",但是如果它包含一个值,则需要显示该值.
and so on (too much to copy and paste). Basically what I want to do is find out whether the value of data:[0,null] is null, and then create an if else statement dependant on the result. If it is null, I need to show a message saying "No data available", but if it contains a value I need the value to be displayed.
有人可以解释一下我如何访问该特定值吗?
Could someone explain how I'd access that specific value please?
感谢您的帮助
推荐答案$return=json_decode($return); if($return['data'][0]){ // what to do if null }else{ // what to do if not (alternatively use elseif()) }
更多推荐
访问特定的JSON值
发布评论