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! 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). 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! 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
Archived
This topic is now archived and is closed to further replies.