ayok Posted November 13, 2010 Share Posted November 13, 2010 Hi, I failed to merge arrays. This is the case. $arraylength= 2; for($i=0;$i<$arraylength;$i++){ $vars[] = array( $key1[$i] => $value1[$i], $key2[$i] => $avalue2[$i], $key3[$i] => $avalue3[$i]); } print_r($vars); I got then, for example, this output Array( [0] => Array ( [key0] => value1, [key0] => value1, [key2] => value2 ) [1] => Array ( [key10] => value10, [key11] => value11, [key12] => value12 ) ) Then I need to merge those two arrays. It should be like array_merge($vars[0],$vars[1]);, but how can i merge more arrays? Thank you in advanced, ayok Link to comment https://forums.phpfreaks.com/topic/218562-array_merge/ Share on other sites More sharing options...
BlueSkyIS Posted November 13, 2010 Share Posted November 13, 2010 array_merge() takes an unlimited number of arrays: $merged_array = array_merge($array1, $array2, $array3, $array4, $array_etc); Link to comment https://forums.phpfreaks.com/topic/218562-array_merge/#findComment-1133790 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.