redd 發表於 2020-10-15 19:13:45

Numbers

The (int), (integer), or intval() function are often used to convert a value to an integer.
<?php
// Cast float to int
$x = 23465.768;
$int_cast = (int)$x;
echo $int_cast;

echo "<br>";

// Cast string to int
$x = "23465.768";
$int_cast = (int)$x;
echo $int_cast;
?>結果:
23465
23465
頁: [1]
查看完整版本: Numbers