Combine arrays

Hi how do I combine or merge the following 2 arrays in php without looping? Any help is appreciated.

$first = array( "apple", "orange" );
$second = array( "pear" );

// Needed the output to be:
array( "apple", "orange", "pear" );

// I have tried array_merge but it seems doesn't work?
array_merge( $first, $second );

I’m sorry array_merge works. I just forgot to assign the result to the variable, dumb me. :frowning:

In what way is it not working, are you getting an error? array_merge should work:


$first = array( "apple", "orange" );

$second = array( "pear" );

$third=array_merge( $first, $second );



Why? What result does it give you?

ok, problem solved :smiley: