我已经运行了下面的代码$api_key = 'XXXXXXXXX';$api_url = "http://sms.eduapp.com:8381/app/miscapi/".$api_key."/getBalance/true/";$credit_balance = file_get_contents( $api_url);echo $credit_balance;并得到输出 [{"ROUTE_ID":"101057","ROUTE":"SMSWAY_TRANS","BALANCE":"13700"}]从上面的输出中,我只想在 php 变量中获取值 13700。提前致谢 :)
2 回答
哔哔one
TA贡献1854条经验 获得超8个赞
$credit_balance = file_get_contents($api_url);
$balance = json_decode($credit_balance, true);
echo $balance[0]['BALANCE'];
或者:
$credit_balance = file_get_contents($api_url);
$balance = json_decode($credit_balance);
echo $balance[0]->BALANCE
当年话下
TA贡献1890条经验 获得超9个赞
该网站返回给你一个数组试试这个
$api_key = 'XXXXXXXXX';
$api_url = "http://sms.eduapp.com:8381/app/miscapi/".$api_key."/getBalance/true/";
$credit = file_get_contents( $api_url);
// sorry im forgot to decode th json
$credit_balance = json_decode($credit, true);
echo $credit_balance['BALANCE'];
- 2 回答
- 0 关注
- 437 浏览
添加回答
举报
0/150
提交
取消