假设我有一些看起来像这样的数据库行:
group version tool info
group_a m screwdriver for screwing things
group_a m hammer for hitting things
group_a l screwdriver for screwing things
group_a xl screwdriver for screwing things
group_b m screwdriver for screwing things
group_b m hammer for hitting things
group_b m wrench for wrenching things
group_b l screwdriver for screwing things
group_b xl wrench for wrenching things
从那我想创建一个看起来像这样的数组:
array(
array( 'id' => 'group_a',
array( 'id' => 'm',
array( 'id' => 'screwdriver',
'info' => 'for screwing things'
),
array( 'id' => 'hammer',
'info' => 'for hitting things'
),
),
array( 'id' => 'l',
array( 'id' => 'screwdriver',
'info' => 'for screwing things'
),
),
array( 'id' => 'xl',
array( 'id' => 'screwdriver',
'info' => 'for screwing things'
),
)
array( 'id' => 'group_b',
array()
)
~~~~~~~ etc ~~~~~~~
);
对于一些上下文,我将其作为 JSON 从 Zend 传递到 BackboneJS,然后将这些数组消耗到一个组集合中,其中包含 n 个版本集合,其中包含 n 个工具模型。
收到任何帮助,很高兴澄清任何问题。
干杯。