Php 四舍五入价格,最接近xx.99美元
我想将价格(向上或向下)四舍五入到最接近的xx.99美元 例如:Php 四舍五入价格,最接近xx.99美元,php,rounding,Php,Rounding,我想将价格(向上或向下)四舍五入到最接近的xx.99美元 例如: $17.99 -> Stay as is $22.03 -> $21.99 $33.85 -> $33.99 $45 -> $44.99 加上0.01,四舍五入,减去0.01 $input = 17.99; // example input $add = $input + 0.01; $round = round($add); $output = $round - 0.01; 或一体式: retu
$17.99 -> Stay as is
$22.03 -> $21.99
$33.85 -> $33.99
$45 -> $44.99
加上0.01,四舍五入,减去0.01
$input = 17.99; // example input
$add = $input + 0.01;
$round = round($add);
$output = $round - 0.01;
或一体式:
return round($input + 0.01) - 0.01;
只需轮($price)-0.01如何?