Robbrad Posted October 19, 2009 Share Posted October 19, 2009 Hi Guys I have a function that returns a multidimentional array eg $result = function(param) echo $result[0][1]." ".$result[1][1] but I want to call the function 4 diffrent times and append to the array prevuiously returned is this possable? and if so how do i do it (dont really want 4 arrays and to recurse through each.) Link to comment https://forums.phpfreaks.com/topic/178220-solved-multi-dimensional-array-append/ Share on other sites More sharing options...
cags Posted October 19, 2009 Share Posted October 19, 2009 array_merge should do the job. Link to comment https://forums.phpfreaks.com/topic/178220-solved-multi-dimensional-array-append/#findComment-939645 Share on other sites More sharing options...
Robbrad Posted October 19, 2009 Author Share Posted October 19, 2009 Iv tried that but all it seams to do is display the first array iv done an print r of the merge array and the first array is displayed then i did a print of the two arrays to be merge and they show all the results - its really odd the function returns the same type of array - why should they not merge Link to comment https://forums.phpfreaks.com/topic/178220-solved-multi-dimensional-array-append/#findComment-939683 Share on other sites More sharing options...
cags Posted October 19, 2009 Share Posted October 19, 2009 Can you post the actual code your using for the merge? Link to comment https://forums.phpfreaks.com/topic/178220-solved-multi-dimensional-array-append/#findComment-939700 Share on other sites More sharing options...
cags Posted October 19, 2009 Share Posted October 19, 2009 Here's a quick example.. $arr1 = array(array(1, 2, 3, 4), array("one", "two", "three", "four")); $arr2 = array(array(5, 6, 7, , array("five", "six", "seven", "eight")); $arr = array_merge($arr1, $arr2); print_r($arr); Link to comment https://forums.phpfreaks.com/topic/178220-solved-multi-dimensional-array-append/#findComment-939708 Share on other sites More sharing options...
Robbrad Posted October 19, 2009 Author Share Posted October 19, 2009 I got it working thanks I needed to specify the eliments of the array to merge eg $Array[0] = array_merge($a1[0],a2[0]); $Array[1] = array_merge($a1[1],a2[1]); I now how a marged array! Thanks Link to comment https://forums.phpfreaks.com/topic/178220-solved-multi-dimensional-array-append/#findComment-939722 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.