Rumah >pembangunan bahagian belakang >tutorial php > 解析JSON的有关问题
解析JSON的问题
<br /> {<br /> "code":"A0001",<br /> "serverTime":12345,<br /> "data":[<br /> {"epgId":"1103226854","endTime":"12000"},<br /> {"epgId":"1103226855","endTime":"12300"},<br /> {"epgId":"1103226857","endTime":"12350"},<br /> {"epgId":"1103226858","endTime":"12356"}<br /> ]<br /> }<br />
$s='{<br /> "code":"A0001",<br /> "serverTime":12345,<br /> "data":[<br /> {"epgId":"1103226854","endTime":"12000"},<br /> {"epgId":"1103226855","endTime":"12300"},<br /> {"epgId":"1103226857","endTime":"12350"},<br /> {"epgId":"1103226858","endTime":"12356"}<br /> ]<br /> }';<br /> $arr=json_decode($s,true);<br /> foreach($arr['data'] as $v){<br /> if($v['endTime']>$arr['serverTime']){ <br /> echo $v['epgId'];<br /> break;<br /> } <br /> }