I'm trying to merge 2 arrays without losing values:
$a = array('one', 'two', 'three');
$b = array('four', 'five', 'six');
The result I need is:
array('one', 'two', 'three', 'four', 'five', 'six');
I know this could be done using a loop + [] operator but it seems like a common task and I'm looking for a simpler solution, maybe using build in array functions. Any suggestions?
Syntax : array array_merge ( array $array1 [, array $... ] )
array_merge($a,$b);
You can use array_merge(); function like :
$result = array_merge($array1, $array2);
array_merge()
should do the trick.
array array_merge ( array $array1 [, array $... ] )