PHP判断JSON数据类型

判断PHP变量数据变量

gettype($first) //$first为要判断的变量

返回类型
PHP判断JSON数据类型

$DecryptMsg数据

{"DataList":[{"address":"测试门禁_80692","baseMacAddr":"xx:xx:xx:xx:xx:xx","checkTime":1611793083000,"corpId":"你自己的","groupId":"你自己的","bizId":"E6C151496AC6DF9FE68D6AEED5824667","locationMethod":"ATM","checkByUser":true,"deviceName":"测试门禁_80692","deviceSN":"xxxxxxxxxxxx","userId":"xxxxxxxxxxxx"}],"EventType":"attendance_check_record"}

$arrmsg= json_decode($DecryptMsg);  

$arrmsg->DataList为数组类型

$first = array_shift($arrmsg->DataList); //取第一个数组元素

$first为对象object

我的目的读取"locationMethod":“ATM”

$first->locationMethod

返回结果
ATM
结束

上一篇:js实现简易ATM功能


下一篇:Android IOS WebRTC 音视频开发总结(九)-- webrtc入门001