ja_blackburn Posted January 19, 2011 Share Posted January 19, 2011 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! Quote Link to comment https://forums.phpfreaks.com/topic/224938-help-with-joiningmerging-two-array-values-together/ Share on other sites More sharing options...
bh Posted January 19, 2011 Share Posted January 19, 2011 hi, with array_map function you can easily do this (see example 3 on the manual page). Quote Link to comment https://forums.phpfreaks.com/topic/224938-help-with-joiningmerging-two-array-values-together/#findComment-1161798 Share on other sites More sharing options...
ja_blackburn Posted January 19, 2011 Author Share Posted January 19, 2011 Thanks bh - have a good day! Quote Link to comment https://forums.phpfreaks.com/topic/224938-help-with-joiningmerging-two-array-values-together/#findComment-1161802 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.