約 200 レコードの配列があり、次のようになります。
[0] => Array
(
[sid] => 54
[sname] => vISL User book
[sdate] => 2012-03-01 00:00:00
[pid] => 262
[cid] => 95
[at] =>
[amount] => 0
[psdate] => 2012-03-14 00:00:00
[first_name] => Alan
[last_name] => Darshan
[pcid] => 95
[cname] => Invisal
)
[1] => Array
(
[sid] => 54
[sname] => vISL User book
[sdate] => 2012-03-01 00:00:00
[pid] => 263
[cid] => 94
[at] =>
[amount] => 0
[psdate] => 2012-03-14 00:00:00
[first_name] => umed
[last_name] => sarkar
[pcid] => 92
[cname] => Tisal
)
この配列を次の形式に変換したいと思います。その理由は、sid、sname、および sdate の組み合わせが、pid、cid ... cname の複数の値を持つ可能性があるためです。
[0] => Array
(
[sid] => 54
[sname] => vISL User book
[sdate] => 2012-03-01 00:00:00
[parr] => Array
(
[0] => Array
(
[pid] => 262
[cid] => 95
[at] =>
[amount] => 0
[psdate] => 2012-03-14 00:00:00
[first_name] => Alan
[last_name] => Darshan
[pcid] => 95
[cname] => Invisal
)
[1] => Array
(
[pid] => 262
[cid] => 95
[at] =>
[amount] => 0
[psdate] => 2012-03-14 00:00:00
[first_name] => Alan
[last_name] => Darshan
[pcid] => 95
[cname] => Invisal
)
)
)
[1] => Array
(
[sid] => 53
[sname] => tebby book
[sdate] => 2012-04-01 00:00:00
[parr] => Array
(
[0] => Array
(
[pid] => 162
[cid] => 15
[at] =>
[amount] => 1
[psdate] => 2012-03-14 00:00:00
[first_name] => edbey
[last_name] => balh
[pcid] => 93
[cname] => Ansasa
)
[1] => Array
(
[pid] => 212
[cid] => 92
[at] =>
[amount] => 0
[psdate] => 2012-03-14 00:00:00
[first_name] => xyz
[last_name] => def
[pcid] => 91
[cname] => vsall
)
)
)
配列の必要な構造を取得する最良の方法は何でしょうか?