What are some potential pitfalls when rounding numbers in PHP?

One potential pitfall when rounding numbers in PHP is that the round() function may not always behave as expected due to the way it handles decimal values. To ensure accurate rounding, it is recommended to use number_format() function with the desired precision. This function formats a number with grouped thousands and decimal points.

$number = 10.555;
$rounded_number = number_format($number, 2);
echo $rounded_number; // Output: 10.56