<?php
$arr = [ [1,2,4], [4,2,6], [2,1,8] ];
// in each sub-array's end elemnent
//add previous sub-array's end-element
how to do with for iteration
?>
Here you go..,
<?php
$arr = [ [1,2,4], [4,2,6], [2,1,8] ];
$sum = 0;
foreach ($arr as $subarray) {
$last_element;
foreach ($subarray as $val) {
$last_element = $val;
}
$sum = $sum + $last_element;
}
echo $sum;
?>