Jump to content

Merge Array Question


ja_blackburn

Recommended Posts

Hi.

 

I have two arrays:

 

$one =  array('a', 'b', 'c');
$two = array('123', '456', '789');

 

My desired output is:

 

$output = array('123a', '123b', '123c', '456a', '456b', '456c', '789a', '789b', '789c' )

 

How can this be achieved, I have looked into functions such as array_merge() but it doesnt seem to do the job.

 

Help greatly appreciated!

 

 

Link to comment
https://forums.phpfreaks.com/topic/225109-merge-array-question/
Share on other sites

Hi

 

Thanks for that.

 

The output i'm getting is:

 

Array ( [0] => 123a [1] => 456b [2] => 789c )

 

So its not quite:

 

$output = array('123a', '123b', '123c', '456a', '456b', '456c', '789a', '789b', '789c' )

 

Any Ideas on how I can get it apply each item from $one to $two in consecutive groups of three?

 

Cheers.

 

 

 

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.