xxxxxxxxxx
//before your operation, check if the divisior has 0 value
if (doubleval($divisor) == 0.0) {
$divisor = 1;
}
xxxxxxxxxx
//before your operation, check if the divisior has 0 value
if (doubleval($divisor) == 0.0) {
$divisor = 1;
}
xxxxxxxxxx
// just use null coalescing operator
number_format((0 / (0 ?: 1))); // 0
⊦------⊣
there is
// or if your number/decimal comes from database which is "string" data type,
// do it like this: (php-bcmatch is required)
number_format(("0.00" / ("0.000" == bcadd(0,0,3) ? "1" : "0.000"))); // 0