0

Supposing I have these arrays:

$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');

How to combine them into one multidimensional array like this:

$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'))

I have tried using array_map but it is not producing the array I need. Thanks.

3 Answers 3

4

Are you looking for $groups = array($group1, $group2, $group3); ?

Sign up to request clarification or add additional context in comments.

1 Comment

oh my God, so simple. Thank you.
1
$new_arr = array($group1,$group2,$group3);

Comments

0
$groups[] = array_merge ($group1,$group1,$group1);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.