我正从sql server检索数据,然后以有条理的方式呈现它们
我有一个这样的对象数组:
Array
(
[0] => stdClass Object
(
[post_id] => 1
[controller] => Cato
[controller_method] => edit
[http_method] => post
)
[1] => stdClass Object
(
[post_id] => 1
[controller] => Cato
[controller_method] => edit
[http_method] => get
)
[2] => stdClass Object
(
[post_id] => 1
[controller] => Cato
[controller_method] => create
[http_method] => post
)
[3] => stdClass Object
(
[post_id] => 1
[controller] => Cato
[controller_method] => create
[http_method] => get
)
)
不知怎的,我需要转换成这样的东西:
Array(
[0] => Array(
[controller] => controller1,
[controller_methods] => Array (
[0] => Array (
[controller_method] => create,
[http_methods] => Array (
[0] => get,
[1] => post
)
),
[0] => Array (
[controller_method] => edit,
[http_methods] => Array (
[0] => get,
[1] => post
)
)
)
),
[0] => Array(
[controller] => controller2,
[controller_methods] => Array (
[0] => Array (
[controller_method] => create,
[http_methods] => Array (
[0] => get,
[1] => post
)
),
[0] => Array (
[controller_method] => edit,
[http_methods] => Array (
[0] => get,
[1] => post
)
)
)
)
)
当使用带有sql db的php时,我总是遇到这样的事情 有没有方便的方法呢?