Array Structure -> Suggestions welcomed
Posted: Mon Dec 21, 2009 12:09 pm
I'm currently working on project that requires monthly accounting reports. I have just finished the first report, and would like some suggestions on the structure of the array used for the totals on the report.
The report shows what money has been received in a given time period and how that money was taken, cash, credit card, bank transfer etc. The report requires grand totals for the whole report and a break down on a month by month basis, both of which are further broken down by how the payment was taken.
Here is an example
Payment Type Totals
Cheque 75.00
Cash 250.00
Bank Transfer 100.00
Total Amount Received 425.00
September 2009
Cheque 75.00
Totals for September 2009 75.00
December 2009
Cash 250.00
Bank Transfer 100.00
Totals for December 2009 350.00
To achieve this I have created a multi-dimensional array to hold all the data necessary to produce the final totals.
It's current structure is as shown below :
I was thinking of tidying it up, and changing it to this :
Please bare in mind that I DO want to print the array names as these will be used as headers.
Is this structure ok, or is there a better way of organising the array? If you have any suggestions please let me know.
I'm leaving it for the night now, look forward to your responses tomorrow.
Thanks!
The report shows what money has been received in a given time period and how that money was taken, cash, credit card, bank transfer etc. The report requires grand totals for the whole report and a break down on a month by month basis, both of which are further broken down by how the payment was taken.
Here is an example
Payment Type Totals
Cheque 75.00
Cash 250.00
Bank Transfer 100.00
Total Amount Received 425.00
September 2009
Cheque 75.00
Totals for September 2009 75.00
December 2009
Cash 250.00
Bank Transfer 100.00
Totals for December 2009 350.00
To achieve this I have created a multi-dimensional array to hold all the data necessary to produce the final totals.
It's current structure is as shown below :
Code: Select all
Array
(
[totalReceived] => 425
[payTypeHeads] => Array
(
[0] => Cheque
[1] => Cash
[2] => Bank Transfer
)
[payTypeTotals] => Array
(
[0] => 75
[1] => 250
[2] => 100
)
[monthTotals] => Array
(
[0] => Array
(
[month] => September 2009
[1] => Array
(
[payType] => Cheque
[payTotal] => 75.00
)
)
[1] => Array
(
[month] => December 2009
[1] => Array
(
[payType] => Cash
[payTotal] => 250
)
[2] => Array
(
[payType] => Bank Transfer
[payTotal] => 100.00
)
)
)
)
Code: Select all
Array
(
[totalReceived] => 425
[payTypeHeads] => Array
(
[Cheque] => 75
[Cash] => 250
[Bank Transfer] => 100
)
[monthTotals] => Array
(
[September 2009] => Array
(
[Cheque] => 75.00
)
[December 2009] => Array
(
[Cash] => 250
[Bank Transfer] => 100.00
)
)
)
Is this structure ok, or is there a better way of organising the array? If you have any suggestions please let me know.
I'm leaving it for the night now, look forward to your responses tomorrow.
Thanks!