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
https://forums.phpfreaks.com/topic/13165-array_merge_recursive-on-the-same-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.