Jak správně zaokrouhlit řetězec PHP na dvě desetinná místa?
$number = "520"; // It's a string from a database
$formatted_number = round_to_2dp($number);
echo $formatted_number;
Výstup by měl být 520.00
;
Jak by měla vypadat definice funkce round_to_2dp()
?
http://php.net/manual/en/function.round.php
Např.
echo round(5.045, 2); // 5.05
echo round(5.055, 2); // 5.06