Jump to content

Array_merge_recursive() On The Same Array


eviltwinkie

Recommended Posts

Very simple question which either I am smoking crack and therefore cannot see the answer...or is just impossible to do. Using PHP5...

$array =
[0] => Array ( [Misc] => Blah )
[1] => Array ( [Animals] => Moo )
[2] => Array ( [Animals] => Oink )
[3] => Array ( [Stuff] => Thing1 )
[4] => Array ( [Stuff] => Thing2 )

All I need to accomplish is to....

$result = array_merge_recursive($array['0'],$array['1'],$array['2'],$array['3'],$array['4']);

Which yields...

$result =
[Misc] => Blah
[Animals] => Array ( [0] => Moo [1] => Oink )
[Stuff] => Array ( [0] => Thing1 [1] => Thing2 )

no problem there...however I do NOT know how many arrays I will need to list within the array_merge_recursive() function...so I tried to do a count and create a variable with the array broken into the proper format with the "," between them like...

$variable = $array['0'],$array['1'],$array['2'],$array['3'],$array['4'];

however array_merge_recursive($variable) refuses to work...

soooooo...the million dollar question is....

how can I either load up a variable properly formatted which the array_merge_recursive function will accept?

OR

how can I do an array_merge_recursive($array['0'],$array['1],etc,etc,etc, until EOF??)

Any takers??







Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.