[Solved] Limiting remainder in php


A billion ways to do this. The task for you here is to pick one.

Method 1 – round()

This will just round your number. The exact rules can be found in the PHP.net documentation.

round($someNumber, 2);

Method 2 – floor()

Floor will round the number down

floor($someNumber, 2);

Method 3 – ceil()

Opposite to floor() this will round your number upwards.

ceil($someNumber, 2);

Method 4 – number_format()

This will format any number. number_format() has a gazillion possible inputs in which you can choose decimal characters etc.

// Will round your number to 2 decimals with a . as decimal character
number_format($someNumber, 2, ",", ".");

Feel free to edit and add more options 🙂

solved Limiting remainder in php