Let say I have a function inside a controller of a CI
public function mr_printing () {
$code = $_POST ['item_id'] ;
$count = count($code) ;
for ($i=0; $i < $count; $i++) {
$idline = $code [$i] ;
$new ['item'] = $this -> model_prcsys -> get_line_data (md5(base64_decode($idline))) ;
$arr = $this -> model_prcsys -> get_sum_received ($new ['item'] ['pr_line_id']) ;
$sum = ($arr) ;
print_r($sum);echo "<br><br>";
}
}
by that, I have output :
Array ( [0] => Array ( [qty_incoming] => 5 ) [1] => Array ( [qty_incoming] => 2 ) )
Array ( [0] => Array ( [qty_incoming] => 3 ) )
From the first array, I need to get value from SUM for every array. In another word, I need output like this:
7
3
Anyone, please?
array_sum(array_column($arr, 'qty_incoming'));