I have seen read other posts that are almost similar to my problem.
but I can't find the right answer to my problem.
here I have a $data[4] array that is like the following.
Array ( [0] => 0.84 ) Array ( [0] => 2.79 )
and this my php code for calculating the value in variable $data[4]
$a= array();
foreach(array($data[4]) as $datas) {
$a[] = $datas;
}
print_r($a);
$sum = array_sum($a);
echo $sum;
}
but the results are not calculating, instead of displaying values from the data array $data[4]
like this
0.84
2.79
You got two arrays with
0index in$data[4]. You have to flatten this$a, you can add extra foreach.By the way - consider using
var_exportto show more precisely what's in your data :)