for($i=0;$i<count($arr);$i++)
{ $feetype= array(); $feetypeamount = array();
for($j=$i+1;$j<count($arr);$j++)
{
if(($arr[$i]['student_id']==$arr[$j]['student_id'])&&($arr[$i]['admission_no']==$arr[$j]['admission_no']))
{
if($arr[$i]['type'] != $arr[$j]['type']) { array_push($feetypeamount, $arr[$i]['amount1']); }
if($arr[$i]['type'] != $arr[$j]['type']) { array_push($feetype,$arr[$i]['type']); }
array_push($feetypeamount, $arr[$j]['amount1']);
array_push($feetype,$arr[$j]['type']);
$arr[$i]['amount'] = $arr[$i]['amount']+$arr[$j]['amount'];
unset($arr[$j]);
}
}
$type= implode(" \ ",array_unique($feetype));
if(isset($type) and !empty($type)){ $arr[$i]['type'] = implode(" \ ",array_unique($feetype)); }
if(isset($feetypeamount) and !empty($feetypeamount)){ $arr[$i]['amount1'] = array_sum(array_unique($feetypeamount)); }
}
This is multidimensional-array
If Student Id is the same then This PHP script will marge fees of students and show only one row
[0] => Array
(
[id] => 5
[student_fees_master_id] => 1511
[fee_groups_feetype_id] => 13
[firstname] => Janhavi
[lastname] => Thengal
[class_id] => 6
[class] => 3rd
[admission_no] => 151048
[section] => B
[section_id] => 2
[student_id] => 533
[name] => Tuition fees 11000
[type] => Tuition Fees 11000
[code] => TUITFE11000
[amount1] => 11000.00
[student_session_id] => 1979
[amount] => 7000
[date] => 2020-06-04
[amount_discount] => 0
[amount_fine] => 0
[description] => r no 212 Collected By: Super Admin(9000)
[payment_mode] => Cash
[inv_no] => 1
[received_by] => 1
[received_byname] => Array
(
[name] => Super Admin
[employee_id] => 9000
[id] => 1
)
)
[1] => Array
(
[id] => 8
[student_fees_master_id] => 1466
[fee_groups_feetype_id] => 13
[firstname] => Prajwal
[lastname] => Nalwade
[class_id] => 6
[class] => 3rd
[admission_no] => 121010
[section] => A
[section_id] => 1
[student_id] => 483
[name] => Tuition fees 11000
[type] => Tuition Fees 11000
[code] => TUITFE11000
[amount1] => 11000.00
[student_session_id] => 1925
[amount] => 2000
[date] => 2020-06-04
[amount_discount] => 0
[amount_fine] => 0
[description] => R no 215 Collected By: Super Admin(9000)
[payment_mode] => Cash
[inv_no] => 1
[received_by] => 1
[received_byname] => Array
(
[name] => Super Admin
[employee_id] => 9000
[id] => 1
)
)
[2] => Array
(
[id] => 10
[student_fees_master_id] => 2050
[fee_groups_feetype_id] => 13
[firstname] => Rajaram
[lastname] => Khaire
[class_id] => 10
[class] => 7th
[admission_no] => 15 1116
[section] => C
[section_id] => 3
[student_id] => 1151
[name] => Tuition fees 11000
[type] => Tuition Fees 11000
[code] => TUITFE11000
[amount1] => 11000.00
[student_session_id] => 2493
[amount] => 4000
[date] => 2020-06-10
[amount_discount] => 0
[amount_fine] => 0
[description] => R No 239 Collected By: Super Admin(9000)
[payment_mode] => Cash
[inv_no] => 1
[received_by] => 1
[received_byname] => Array
(
[name] => Super Admin
[employee_id] => 9000
[id] => 1
)
)
No comments:
Post a Comment