What are some common methods for rounding values in PHP based on specific criteria?

When working with numerical values in PHP, it is often necessary to round these values based on specific criteria such as rounding to a certain number of decimal places, rounding up or down, or rounding to the nearest whole number. Some common methods for rounding values in PHP include using functions like round(), ceil(), and floor().

// Rounding a value to a specific number of decimal places
$value = 10.56789;
$rounded_value = round($value, 2); // Rounds to 2 decimal places

// Rounding up to the nearest whole number
$value = 10.1;
$rounded_value = ceil($value); // Rounds up to 11

// Rounding down to the nearest whole number
$value = 10.9;
$rounded_value = floor($value); // Rounds down to 10