Truncate float numbers with PHP

floor will do as you ask.

floor(45.8976 * 100) / 100;

You won’t find a more direct function for this, since it’s a kind of odd thing to ask. Normally you’ll round mathematically correct. Out of curiosity – What do you need this for?

Leave a Comment