- Edited
I've got a database which I'm looping through. Grouping results by year with a summary of spend then placing it all into an array
I've done the first level of my array like below. Setting my $data variable and adding first layer information to it.
My question is within my foreach loop I want to run a further query and do the same thing for monthly totals and then again within each month for
So my data will be
Year Summary
Month Summary
Month Details
Year Summary
Month Summary
Month Details
Year Summary
Month Summary
Month Details
How can I add an array into my array object
$data = [];
foreach ($getRows as $row){
$data[$YearCalc] = ['Year' => $row['YearCalc'], 'Credit' => $row['Credit'], 'Debit' => $row['Debit']];
}
var_dump(array_values($data));