源数组:
["data"] => array(10) {
["type"] => string(10) "controller"
["name"] => string(3) "eg1"
["description"] => string(5) "desc1"
["type2"] => string(8) "function"
["name2"] => string(2) "c2"
["controller2"] => string(4) "welcome"
["description2"] => string(6) "desc 2"
["type3"] => string(10) "controller"
["name3"] => string(2) "c3"
["description3"] => string(8) "c3 descr"
}
从上面的数组我怎样才能获得新的数组:
array(
array(
'type' => 'controller',
'name' => 'eg1',
'description' => 'desc1'
),
array(
'type' => 'function',
'controller' => 'welcome',
'name' => 'c2',
'description' => 'desc 2'
),
array(
'type' => 'controller',
'name' => 'eg1',
'description' => 'desc1'
),
array(
'type' => 'controller',
'name' => 'c3',
'description' => 'c3 descr'
)
);
数据通过https://github.com/tristandenyer/Clone-section-of-form-using-jQuery
提交感谢您的帮助
答案 0 :(得分:1)
这不是一个关联数组,它只是一个二维数组,包含3个组中原始数组的元素。您可以使用array_chunk
。
$new_array = array_chunk($array, 3);