我试图重现以下内容作为一行代码。PHP:每次增加一个数字5
if($l < 10) $next = 5; return;
if($l < 20) $next = 10; return;
if($l < 30) $next = 15; return;
if($l < 40) $next = 20; return;
if($l < 50) $next = 25; return;
if($l < 60) $next = 30; return;
if($l < 70) $next = 35; return;
if($l < 80) $next = 40; return;
if($l < 90) $next = 45; return;
if($l < 100) $next = 50; return;
(语法上不正确的,但你的想法)
因此,如果数小于10,$其次是5,如果数量少于20那么它的10
$next = ((round($l, -1)-5));
是接近我可以得到它,但是,让
5
15
25
35
45
55
65
75
85
没有预期的5,10,15,20 ..等
写这个的正确方法是什么?
其中一个括号没有正确关闭 – penu 2012-01-28 08:47:00
抱歉(固定它)...但我的回答比您选择的答案“更加严格”,因为如果您没有确定结果得到一个不是四舍五入的数字,在我的例子中你会得到5.7 * 5 = 28.5。 – 2012-01-28 08:59:51
好的,谢谢:) .. – penu 2012-01-28 09:03:18