Cast float to int PHP

> Convert float to integer
> Round float
> Get the next integer
> Abs() method
> Get the absolute value
> Cast double to int

Description
Cast float to integer


echo intval(42.1); //42
echo intval(42.9); //42

echo (int)42.1; //42
echo (int)42.9; //42
echo (integer)42.9; //Same as (int), 42

echo round(3.4); // 3
echo round(3.5); // 4

echo round(9.5, 0, PHP_ROUND_HALF_UP);   // 10
echo round(9.5, 0, PHP_ROUND_HALF_DOWN); // 9
echo round(9.5, 0, PHP_ROUND_HALF_EVEN); // 10
echo round(9.5, 0, PHP_ROUND_HALF_ODD);  // 9

echo round(8.5, 0, PHP_ROUND_HALF_UP);   // 9
echo round(8.5, 0, PHP_ROUND_HALF_DOWN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_EVEN); // 8
echo round(8.5, 0, PHP_ROUND_HALF_ODD);  // 9

SEE ALSO