How can one customize the rounding behavior in PHP to consider all decimal places, not just the ones after the specified precision?

When using the round() function in PHP, by default it only considers the decimal places specified in the precision parameter. If you want to customize the rounding behavior to consider all decimal places, you can achieve this by multiplying the number by a power of 10, rounding it, and then dividing it back by the same power of 10.

function customRound($number, $precision) {
    $multiplier = pow(10, $precision);
    return round($number * $multiplier) / $multiplier;
}

// Example usage
$number = 3.14159;
$roundedNumber = customRound($number, 2);
echo $roundedNumber; // Output: 3.14