Removing all decimals in PHP
As Tricker mentioned you can round the value down or you can just cast it to int like so:
$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.
You can do a simply cast to int
.
$var = 252.587254564;
$var = (int)$var; // 252
You can do it in PHP:
round($val, 0);
or in your MYSQL statement:
select round(foo_value, 0) value from foo
In PHP you would use:
$value = floor($value);
floor
: Returns the next lowest integer value by rounding the value down if necessary.
If you wanted to round up it would be:
$value = ceil($value);
ceil
: Returns the next highest integer value by rounding the value up if necessary.