I have this code to fetch data from remote API which returns folowing RAW data
{"BTC":0.00002067,"USDT":1,"DOGE":21.53}
and/or following Object
stdClass Object ( [BTC] => 2.056E-5 [USDT] => 1 [DOGE] => 21.52
I am using this code
$url = 'https://min-api.cryptocompare.com/data/price?fsym=USD&tsyms=BTC,USDT,DOGE';
$data = file_get_contents($url);
$priceInfo = json_decode($data);
foreach ($priceInfo as $val){
echo "<br>--> ".$val;
}
which returns this
--> 2.056E-5
--> 1
--> 21.52
but I would have this result
--> BTC 0.00002067
--> USDT 1
--> DOGE 21.52
How can reach this result ?
Source: Ask PHP