bcdiv

string bcdiv(string left_operand, string right_operand, [int scale]) 
left_operand Number to divide
right_operand Number to divide by
scale Number of decimal places to return

Divides a value by another value.

Returns:

Division result

Description:

bcdiv() divides the first number by the second number and returns the result, formatted with a specified number of decimal places (optional).

Version:

Existing since version 3.0

Example:

Divide a large number
$num1 = "9912343.34546"; 
$num2 = "34546.9912343"; 
echo bcdiv($num2,$num1,10); 

Output: 
0.0034852496 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.