-2
我有我想檢查價值水平的PHP代碼。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