What function in PHP can be used to truncate a number to a specific number of decimal places?
To truncate a number to a specific number of decimal places in PHP, you can use the number_format() function. This function formats a number with grouped thousands and a specified number of decimal places. By setting the decimal parameter to the desired number of decimal places, you can truncate the number accordingly.
$num = 123.456789;
$truncated_num = number_format($num, 2); // truncates to 2 decimal places
echo $truncated_num; // Output: 123.46