Adnan30pk Adnan30pk - 5 months ago 8
PHP Question

How to merge two or more multi dimensional arrays in PHP to make it one array?

I need a function to solve this issue.

Example:

$ar1 = array("alpha" => array("A","B","C","D"), ...);
$ar2 = array("numerics" => array("1","2","3","4"), ...);

$output = merge_arrays($ar1,$ar2);
print_r($output);


Result:

array("A","B","C","D","1","2","3","4");

Answer
      $output = call_user_func_array('array_merge',
      array_values(array_merge_recursive($ar1,$ar2)));

      print_r($output);