-3

I want to merge two arrays with duplicates For example, $n1 = array(0=>'foo', 1=>'bar', 2=>'baz'); $n2 = array(0=>'lorem', 1=>'ipsum', 2=>'foo'); Results should be,

$result = array(0=>'foo', 1=>'bar', 2=>'baz',3=>'lorem', 4=>'ipsum', 5=>'foo');

I there any predefined function available in PHP

Learner
  • 714
  • 1
  • 5
  • 24

1 Answers1

3

how about array_merge? It does exactly what you need.

$array = array_merge($n1, $n2);
Leon
  • 988
  • 7
  • 20