皮卡丘 大佬有话说 :
这个json怎么写?
{"data":{"sex":"男","address":"山东省-潍坊市-寒亭区","birthday":"1981-11-30"},"resp":{"code":5,"desc":"不匹配"}}
$resp = json_decode($json);
if ($resp[‘resp’][‘code’] == ‘5’) {
msg(‘不匹配!’);
}
if ($resp[‘resp’][‘code’] == ‘1’) {
msg(‘OK!’);
}
我想判断通过后面code的数字来作为判断条件
请问我这样写为啥不对,该怎么写。谢谢大佬帮忙
Gin_Node 大佬有话说 :
楼下来吧 我不会
皮卡丘 大佬有话说 :
Gin_Node 大佬有话说 : 2020-7-30 00:03
楼下来吧 我不会
谢谢帮顶
贴吧 大佬有话说 :
$resp->resp->code
forever8938 大佬有话说 :
数字的单引号去掉试试
皮卡丘 大佬有话说 :
forever8938 大佬有话说 : 2020-7-30 00:06
数字的单引号去掉试试
v2net 大佬有话说 :
$json = ‘{"data":{"sex":"男","address":"山东省-潍坊市-寒亭区","birthday":"1981-11-30"},"resp":{"code":5,"desc":"不匹配"}}’;
$resp = JSON.parse($json);
if ($resp[‘resp’][‘code’] == 5) {
msg(‘不匹配!’);
}
if ($resp[‘resp’][‘code’] == 1) {
msg(‘OK!’);
}