I'm trying to format a decimal number that I've optained from a json object in PHP. My objective is to keep this number with just two places after the comma.
Here is the code:
`
$url = "https://api.yadio.io/exrates/EUR";
$data = json_decode(file_get_contents($url, true));
$object = $data;
foreach($object as $a){
echo round($a->CUP, 2);
}
`
The result without round()
was 163.905765
, so when I apply it, the result is 0163.9100
and should be 163.90
.
Any help will be very appretiate.