[eluser]obiron2[/eluser]
I am returning a results set which contains the following data:
Table number, seat number, First Name, Surname
Ordered by table ASC, Seat ASC so I get
Code:
1,1,Fred,Bloggs
1,2,Joe, Smith
2,1,Bob,Jones
2,2,Mick,Reed
3,1,Mark,Thomas
3,2,Sam,Brown
I want to convert this to a 2 dimensional array with the table number being the outer dimension and the seat and name data being the inner dimension
Code:
$data['Tabledetails'] = array
(array
(Table=>1,
Tabledata => array
(Seat=>1,Fname=>'Fred',Sname=>'Bloggs'),
(Seat=>2,Fname=>'Joe',Sname=>'Smith')
),
(Table=>2,
Tabledata => array
(Seat=>1,Fname=>'Bob', Sname=>'Jones'),
(Seat=>2,Fname=>'Mick', Sname=>'Reed'),
),
(Table=>3,
Tabledata => array
(Seat=>1,Fname=>'Mark', Sname=>'Thomas'),
(Seat=>2,Fname=>'Sam', Sname=>'Brown'),
)
)
Does anyone have a generic function that does this, either into an array or an object. The data is so much easier to work with in the view if it correctly formatted.
Obiron