php float 2 decimais
$foo = "105";
echo number_format((float)$foo, 2, '.', '');
Rich Ratel
$foo = "105";
echo number_format((float)$foo, 2, '.', '');
<?php
var_dump(round(3.4)); // =>3
var_dump(round(3.5)); // =>4
var_dump(round(3.6)); // =>4
var_dump(round(3.6, 0)); // =>4
var_dump(round(5.045, 2)); // =>5.05
var_dump(round(5.055, 2)); // =>5.06
var_dump(round(345, -2)); // =>300
var_dump(round(345, -3)); // =>0
var_dump(round(678, -2)); // =>700
var_dump(round(678, -3)); // =>1000
?>
floatval ($var)
$num = '1,200,998.255';
########## FOR FLOAT VALUES ###########################
echo filter_var($num, FILTER_SANITIZE_NUMBER_FLOAT, FILTER_FLAG_ALLOW_FRACTION);
#output : 1200998.255
########## FOR INTEGER VALUES ###########################
echo filter_var($num, FILTER_SANITIZE_NUMBER_INT);
#output : 1200998
round('1.7983739837398', 3);//1.798
round('1.7983739837398', 2);//1.8