Are there any potential pitfalls in using the round() function in PHP for formatting numbers?

One potential pitfall in using the round() function in PHP for formatting numbers is that it may not always produce the desired results due to the way it rounds numbers. To avoid this issue, you can use number_format() function instead, which allows you to format numbers with more control over decimal precision and rounding.

$number = 123.456789;
$formatted_number = number_format($number, 2); // Rounds to 2 decimal places
echo $formatted_number; // Output: 123.46