Say that I have a variable that outputs a number such as:
17.672
I would prefer the number to display as "17"
Rather than rounding, how would I remove the decimal notation from this number?
| SitePoint Sponsor |
Say that I have a variable that outputs a number such as:
17.672
I would prefer the number to display as "17"
Rather than rounding, how would I remove the decimal notation from this number?

floor() makes it stay as a float, so mark's solution below (same as intval(17.672) ) might be better.PHP Code:floor(17.672);





PHP Code:echo (int)17.672;

PHP Code:echo round(10.5); // Round the number, this example would echo 11.
echo '<br />';
echo floor(10.5); // Round down, this would echo 10.
echo '<br />';
echo ceil(10.3); // Round up, this would be 11.
Thanks guys![]()
Bookmarks