假设我有这些数组:
$group1= array('id' => '1','title' => 'Group 1','description' => 'This is group1');
$group2= array('id' => '2','title' => 'Group 2','description' => 'This is group2');
$group3= array('id' => '3','title' => 'Group 3','description' => 'This is group3');
如何将它们组合成一个多维数组,如下所示:
$groups=array(array('id' => '1','title' => 'Group 1','description' => 'This is group1'),array('id' => '2','title' => 'Group 2','description' => 'This is group2'),array('id' => '3','title' => 'Group 3','description' => 'This is group3'))
我尝试过使用array_map,但它没有生成我需要的数组。感谢。
答案 0 :(得分:4)
您在寻找$groups = array($group1, $group2, $group3);
吗?
答案 1 :(得分:1)
$new_arr = array($group1,$group2,$group3);
答案 2 :(得分:0)
$groups[] = array_merge ($group1,$group1,$group1);