JS example of retaining two decimal places and rounding using the function toFixed()
php example of rounding to two decimal places
1.number_format
$number = 1234.5678;
$nombre_format_francais = number_format($number, 2, ,, );
// 1 234,57
$english_format_number = number_format($number , 2, ., );
// 1234.57
2.round
$number = 1234.5678;
echo round($number ,2);
//1234.57
3.sprintf
$formatted = sprintf ("%s has ¥%01.2f.",$name, $money);
echo $formatted;
//Zhang San has ¥123.10.