grouping array and adding them on CodeIgniter and PHP
Selasa, 20 Maret 2018
Add Comment
![]() |
grouping |
if you want to grouping array in php and summarize them on then create these script
<?php $a=array();
foreach($uraian as $k=>$i){
$key = $i['Uraian'];
if (!array_key_exists($key, $a)) {
$a[$key]= array('Uraian'=>$i['Uraian'],'Total'=>$i['Total']);
} else {
$a[$key]['Total'] = $a[$key]['Total'] + $i['Total'];
}
}
$d['dt'] = $a; ?>
foreach($uraian as $k=>$i){
$key = $i['Uraian'];
if (!array_key_exists($key, $a)) {
$a[$key]= array('Uraian'=>$i['Uraian'],'Total'=>$i['Total']);
} else {
$a[$key]['Total'] = $a[$key]['Total'] + $i['Total'];
}
}
$d['dt'] = $a; ?>
0 Response to "grouping array and adding them on CodeIgniter and PHP"
Posting Komentar