Q
刪除在PHP
7
A
回答
11
你可以在PHP中做到這一點:
round($val, 0);
或在你的MySQL聲明:
select round(foo_value, 0) value from foo
1
可以使用echo (int) 252.587254564;
2
正如Tricker提到你可以圓價值下降,或者你可以把它像這樣int:
$variable = 252.587254564; // this is of type double
$variable = (int)$variable; // this will cast the type from double to int causing it to strip the floating point.
2
您可以只將其轉換爲int
:
$new = (int)$old;
5
你可以做一個簡單的轉換爲int
。
$var = 252.587254564;
$var = (int)$var; // 252
0
在MySQL中,你可以使用:
select floor(field)
或PHP,你可以使用:
floor($value);
4
在PHP中,你可以使用:
$值=地板($值);
floor如有必要,通過舍入值返回下一個最小的整數值。
如果你想圓了這將是
$值=小區($值);
ceil如有必要,通過舍入值返回下一個最高整數值。
0
而且還有一個不太明智的方法:
strtok($value, ".");
第一部分的這削減,直到遇到一個點。結果將是一個字符串,而不是一個PHP整數。雖然它不會影響使用結果,但它不是最好的選擇。
相關問題
- 1. 刪除+ \在Php
- 2. 刪除在PHP
- 3. 刪除在PHP
- 4. PHP刪除「在GET
- 5. 在PHP中刪除
- 6. 刪除PHP
- 7. PHP刪除JavaScript
- 8. 刪除從PHP
- 9. PHP刪除
- 10. 刪除php
- 11. 刪除\「從PHP
- 12. XML刪除項目在PHP
- 13. 刪除的cookie在PHP
- 14. 刪除陣列在PHP
- 15. 刪除週末在php strtotime()
- 16. php:在url中刪除index.php
- 17. 刪除不包含在PHP
- 18. 無法刪除在PHP
- 19. SQL不刪除在php中
- 20. PHP:在url中刪除'?p ='?
- 21. 在PHP中刪除表Mysql
- 22. 在PHP中刪除通知
- 23. 在PHP中刪除一行
- 24. 如何刪除在PHP
- 25. 在PHP中刪除標題
- 26. 的RewriteRules刪除.PHP在URL
- 27. PHP的幫助刪除刪除TD線
- 28. PHP刪除php中的cookie
- 29. Php刪除行onclick
- 30. PHP如何刪除