• Warning: Division by zero – easy way to get arround?

    September 26, 2014

    $sum = [0, 0, 0, 0]; echo count($sum) / array_sum($sum); // Warning: Division by zero $arraySum = 0.00001 + array_sum($sum); $number = count($sum) / $arraySum; echo round($number, 2); // Result is 0; Just add some small number to the one you are not sure that it will be bigger than zero. Easy as that.

 
Powered by Wordpress and MySQL. Theme by Shlomi Noach, openark.org