Jump to content

Help with joining/merging two array values together


ja_blackburn

Recommended Posts

Hello,

 

I want to 'join' two corresponding array values together as in the example below.

 

$one = array('tomato', 'ham', 'bacon');
$two = array('soup', 'sandwich', 'roll');

$final=array(?)

//Desired answer =  (tomatosoup, hamsandwich, baconroll)

 

Is there a php function that can do this, or a series of functions? I am aware of array_merge but this only alternates the values from what I can see.

 

Ideally there should be a check performed that the two are the same length before completing a merge.

 

New to this, many thanks!

 

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.