Answer the question
In order to leave comments, you need to log in
How to fix division by zero?
$data['products'][] = array(
......
'saving' => $result['price'] = round((($result['price'] - $result['spec'] )/$result['price'])*100, 0),
);
but if the variable result['price'] is equal to 0, an error is thrown about division by 0, how can I fix it&
Answer the question
In order to leave comments, you need to log in
$res = $result['price'] - $result['spec'];
if($res <= 0) { ... // что тогда делать
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question