̃Gg[͂ĂȃubN}[Nɒlj

PHP :: 正規表現 / 少数点第2位までに丸める



$val = preg_replace('/(\.[1-9]?[1-9]?)\d*/e', "rtrim('\\1', '.')", $val);
$val = 12345;      => 12345
$val = 12345.6;    => 12345.6
$val = 12345.67;   => 12345.67
$val = 12345.6789; => 12345.67
$val = 12345.6089; => 12345.6
$val = 12345.0089; => 12345



programming/php/regex/float_pos2.txt