我有php代码,我想在其中检查值级别。
我正在解释价值水平
999 or below is level 0
1999 or below & higher then 1000 = level 1
2999 or below & higher then 2000 = level 2
3999 or below & higher then 3000 = level 3 so on....
我无法弄清楚如何检查并执行此操作。我知道这一切都搞砸了,因为我正在使用圆形,但我无法用其他任何方式表达:$level = round($v / 1000);
<?php
$i = 0;
$level = 0;
$v = isset($_GET['v']) ? (int)$_GET['v'] : 100;
do {
$i++;
$bid = round($v / 10);
if ($v > 1000)
{$bid = 100;}
$level = round($v / 1000);
echo "<tr><td>$" . number_format($v) . "</td><td>$" . number_format($bid) . "</td><td>" . $level . "</td></tr>";
$v = $v + $bid;
} while ($i < 5);
?>
输出为:
$348 $35 0
$383 $38 0
$421 $42 0
$463 $46 0
$509 $51 1
$560 $56 1
$616 $62 1
$678 $68 1
$746 $75 1
$821 $82 1
我想要的输出是:
$746 $75 0
$821 $82 0
$903 $90 0
$993 $99 0
$1,092 $100 1
$1,192 $100 1
$1,292 $100 1
$1,392 $100 1