testtongji.php 代碼返回?cái)?shù)據(jù)整理最后想要的結(jié)果
問(wèn)題描述
testtongji.php 代碼如下
<?php error_reporting(0);
$url = 'https://www.zzxxxx.xx/api/wetds/stats/';
$options = array(
'http' => array(
'header' => "Content-Type: application/json",
'header' => "Authorization: Token 633b4deb1cd517a01851a3335811b9ae8e1d6d6d",
'method' => 'GET',
'content' => http_build_query
)
);
$context = stream_context_create($options);
$result = file_get_contents($url, false, $context);
echo ($result);
打開(kāi)testtongji.php 返回?cái)?shù)據(jù)如下
{"bandwidth_used":393073846353,"bandwidth_remaining":680667977647.0,"bandwidth_limit":1073741824000.0,"bandwidth_projected":1496203172977,"last_request_at":"2021-01-13T01:59:38.381732-08:00","requests_total":239278,"requests_successful":238115,"requests_failed":1163,"request_countries":{"US":238334,"NL":848,"RS":96},"requests_error_reasons":{"target_read_deadline":1142,"target_connect_timeout":12,"client_read_timeout":2,"client_read_eof":7},"request_failure_status_codes":{}}
echo ($result);整理如下
需要把以上返回的數(shù)據(jù)整理為以下內(nèi)容 bandwidth_used":393073846353,"bandwidth_remaining":680667977647.0 計(jì)算出393073846353字節(jié) =多少GB 680667977647.0字節(jié)==多少GB 像下面這樣展示出,其他的數(shù)據(jù)都不要
已用流量: XXXX GB
剩余流量: XXXX GB
問(wèn)題解答
回答1:接口數(shù)據(jù)返回給前端, 用js map方法處理就好了
相關(guān)文章:
1. 在應(yīng)用配置文件 app.php 中找不到’route_check_cache’配置項(xiàng)2. 跨類(lèi)調(diào)用后,找不到方法3. sql語(yǔ)句 - 如何在mysql中批量添加用戶(hù)?4. 怎么php怎么通過(guò)數(shù)組顯示sql查詢(xún)結(jié)果呢,查詢(xún)結(jié)果有多條,如圖。5. mysql - 表名稱(chēng)前綴到底有啥用?6. 編輯成功不顯示彈窗7. wamp中的mySQL可以單獨(dú)使用嗎8. 為什么php修改數(shù)據(jù)無(wú)法同步到數(shù)據(jù)庫(kù),只是當(dāng)前頁(yè)面修改成功?9. 哭遼 求大佬解答 控制器的join方法怎么轉(zhuǎn)模型方法10. 在mybatis使用mysql的ON DUPLICATE KEY UPDATE語(yǔ)法實(shí)現(xiàn)存在即更新應(yīng)該使用哪個(gè)標(biāo)簽?
