Problem to split variables in PHP

1

I'm having trouble with a page in php. Whenever I put the following code to split two variables stored in arrays

$dj_cv_at[percentual][$i] = ($dj_cv_at[concluida_c_imp_total][$i] / $dj_cv_at[concluida_total][$i]) * 100;

As a result, the page no longer functions properly.

This only happens when I put the split operator. With the other operators the code runs perfectly.

    
asked by anonymous 07.08.2018 / 20:56

1 answer

0

After analysis I discovered that the problem was related to the division of 0. So to solve this I did the following:

if ($dj_cv_at[concluida_c_imp_total][$i] == 0){ 
$dj_cv_at[percentual][$i] = 0; } 
else {$dj_cv_at[percentual][$i] =($dj_cv_at[concluida_c_imp_total][$i] 
/ $dj_cv_at[concluida_total][$i]) * 100;} 
    
08.08.2018 / 20:23