recursion - How do I break results sets into smaller subsets for subtotaling/hierarchical purposes in PHP? -


i have sizable results sets being returned mysql db need break smaller sets either:

  • adding numbers within subsets subtotaling purposes; or
  • for creating hierarchical table.

the tricky part though need divide results set more once, , number of subdivisions can change per table.
example, might have break results set year , month in order produce subtotals each year/month combination.

i'm trying write php function can take results set , columns split data on , produce new results set divided up.
example, if split data year , month, i'd want have following structure returned:

array(   'divider' => 'year',   'sets' => array(     [0] => array(       'divider' => 'month',       'sets' => array(         [0] => array(), //row returned db         [1] => array(), //row returned db         [2] => array(), //row returned db         ...       )     ),     [1] => array(       'divider' => 'month',       'sets' => array(         [0] => array(), //row returned db         [1] => array(), //row returned db         [2] => array(), //row returned db         ...       )     )     ...   ) ) 

is there way recursively or in way regardless of how many subdivisions there are, type of multidimensional array want?

thank you.


Comments

Popular posts from this blog

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -