php应该怎么获取 code0msg查询成功data withdraw0recharge0otherDatanullcount0
在PHP中,可以使用json_decode()函数将JSON字符串解码为PHP数组或对象。然后可以通过数组索引或对象属性来获取相应的值。对于给定的JSON字符串,可以按照以下方式获取其中的值:
$json = '{"code":0,"msg":"查询成功","data":{ "withdraw":0,"recharge":0},"otherData":null,"count":0}';
// 解码JSON字符串为PHP数组
$data = json_decode($json, true);
// 获取withdraw和recharge的值
$withdraw = $data['data']['withdraw'];
$recharge = $data['data']['recharge'];
echo "withdraw: " . $withdraw . "<br>";
echo "recharge: " . $recharge . "<br>";
输出结果:
withdraw: 0
recharge: 0
通过以上代码,你可以获取到JSON字符串中withdraw和recharge的值
原文地址: https://www.cveoy.top/t/topic/ipxn 著作权归作者所有。请勿转载和采集!