I have tried the PHP code as below:
$i=1;
foreach(getTop5($pid) as $da){
$i++
if($da['index_enjeu_percu'] != NULL){
foreach(getDataChart($pid,$da['index_enjeu_percu']) as $data){
$avg = $data["avg_index_importance"].', ';
$poin_important = substr($avg,0,-2);
$enjeu .= $data["index_enjeu"].', ';
$res_enjeu = substr($enjeu,0,-1);
echo $avg;
}
}
else{
// I want to do the foreach again in here but my data $da['index_enjeu_percu'] == NUll
//I don want to take it as NULL value, I want to take the prevous value of $da['index_enjeu_percu']
foreach(getDataChart($pid,$da['index_enjeu_percu']) as $data){
$avg = $data["avg_index_importance"].', ';
$poin_important = substr($avg,0,-2);
$enjeu .= $data["index_enjeu"].', ';
$res_enjeu = substr($enjeu,0,-1);
echo $avg;
}
}
}
What I want is that : I have loop data as above
Ex: if my result is that: 1 2 3 4 NULL
in case it equal NULL
I want to replace NULL
with 4
I don have the solution for this. Any one help me please, thanks