Код: Выделить всё
$response["rates"][$key[$i]] = (string) round($response["rates"][$key[$i]], 2);
Код: Выделить всё
array(11) {
["result"]=>
string(7) "success"
["provider"]=>
string(32) "https://www.exchangerate-api.com"
["documentation"]=>
string(42) "https://www.exchangerate-api.com/docs/free"
["terms_of_use"]=>
string(38) "https://www.exchangerate-api.com/terms"
["time_last_update_unix"]=>
int(1714003352)
["time_last_update_utc"]=>
string(31) "Thu, 25 Apr 2024 00:02:32 +0000"
["time_next_update_unix"]=>
int(1714090382)
["time_next_update_utc"]=>
string(31) "Fri, 26 Apr 2024 00:13:02 +0000"
["time_eol_unix"]=>
int(0)
["base_code"]=>
string(3) "USD"
["rates"]=>
array(162) {
["USD"]=>
float(1)
["AED"]=>
float(3.6699999999999999289457264239899814128875732421875)
["AFN"]=>
float(72.1299999999999954525264911353588104248046875)
["ALL"]=>
float(94.2999999999999971578290569595992565155029296875)
["AMD"]=>
float(391.30000000000001136868377216160297393798828125)
["ANG"]=>
float(1.79000000000000003552713678800500929355621337890625)
["AOA"]=>
float(843.5700000000000500222085975110530853271484375)
["ARS"]=>
float(864.75)
}
}
Код: Выделить всё
$response["rates"][$key[$i]] = round($response["rates"][$key[$i]], 2);
Остальная часть моего кода работает так, как задумано. Он извлекает данные JSON из URL-адреса и преобразует их в массив.
Вот код с комментариями:
Код: Выделить всё
Подробнее здесь: [url]https://stackoverflow.com/questions/78386286/why-does-casting-the-value-to-a-string-change-the-behavior-of-the-code-in-rewrit[/url]