How can PHP's printf function be used to format decimal values correctly?

When using the printf function in PHP to format decimal values, it is important to specify the correct format specifier for the type of decimal value being displayed. For example, to display a decimal number with a specific number of decimal places, you can use the "%.2f" format specifier to display it with two decimal places. This ensures that the decimal values are formatted correctly and displayed as intended.

$decimalValue = 123.456789;
printf("Formatted decimal value: %.2f", $decimalValue);