How can the bcdiv function in PHP be used to control the number of decimal places in a division result?

When using the bcdiv function in PHP to perform division with arbitrary precision, you can control the number of decimal places in the result by setting the scale parameter. The scale parameter specifies the number of digits after the decimal point in the result. By setting the scale parameter to the desired number of decimal places, you can ensure that the division result is formatted correctly.

$dividend = '10';
$divisor = '3';
$decimal_places = 2;

$result = bcdiv($dividend, $divisor, $decimal_places);

echo $result;