我有這個卷發妝
<?php
$url ="https://min-api.cryptocompare.com/data/price?fsym=USD&tsyms=BTC";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 120,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"Cache-Control: no-cache",
),
));
$response = curl_exec($curl);
$err = curl_error($curl);
$json = json_decode($response);
echo $json->BTC;
curl_close($curl);
試圖獲得 BTC 的價值,我得到1.659E-5而不是0.00001659。請我需要關于如何在沒有這個錯誤數字的情況下對其進行解碼的幫助。
uj5u.com熱心網友回復:
PHP 自動使用科學記數法來顯示 smaaall 數字。
您可以使用 (s)printf() 來控制格式:
// 8 decimals
printf('%.8f', $json->BTC); // 0.00001654
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/338469.html
上一篇:如何驗證端點中的可信客戶端
