PHP : multidimensional array merge recursive
问题 I need to merge those two arrays: $ar1 = array("color" => array("red", "green"), "aa"); $ar2 = array("color" => array( "green", "blue"), "bb"); $result = array_merge_recursive($ar1, $ar2); Expected output: [ 'color' => [ (int) 0 => 'red', (int) 1 => 'green', (int) 3 => 'blue' ], (int) 0 => 'aa', (int) 1 => 'bb' ] But it outputs: [ 'color' => [ (int) 0 => 'red', (int) 1 => 'green', (int) 2 => 'green', (!) (int) 3 => 'blue' ], (int) 0 => 'aa', (int) 1 => 'bb' ] I'm looking for the simplest way