1. $a = array(
  2. 'a',
  3. );
  4. $b = array(
  5. 'u',
  6. );
  7. $c = $a + $b;
  8. var_dump($c);
复制代码

输出:

  1. $a = array(
  2. 66=>'a',
  3. );
  4. $b = array(
  5. 60=>'u',
  6. 66=>'c'
  7. );
  8. $c = $a + $b;
  9. var_dump($c);
复制代码

输出:

  1. 1=>'a',
  2. 2=>'b',
  3. 'c'=>'c',
  4. 'd'=>'d',
  5. );
  6. $b = array(
  7. 1=>'u',
  8. 3=>'v',
  9. 'c'=>'w',
  10. 'd'=>'x',
  11. 'y'=>'y',
  12. 60=>'z',
  13. );
  14. $c = $a + $b;
  15. var_dump($c);
  16. ?>
复制代码

输出:

  1. $a = array(
  2. 'a',
  3. );
  4. $b = array(
  5. 'u',
  6. );
  7. $c = array_merge($a, $b);
  8. var_dump($c);
复制代码

输出:

  1. $a = array(
  2. 66=>'a',
  3. );
  4. $b = array(
  5. 60=>'u',
  6. 66=>'c'
  7. );
  8. $c = array_merge($a, $b);
  9. var_dump($c);
复制代码

输出:

  1. $a = array(
  2. 1=>'a',
  3. 2=>'b',
  4. 'c'=>'c',
  5. 'd'=>'d',
  6. );
  7. $b = array(
  8. 1=>'u',
  9. 3=>'v',
  10. 'c'=>'w',
  11. 'd'=>'x',
  12. 'y'=>'y',
  13. 60=>'z',
  14. );
  15. $c = array_merge($a, $b);
  16. var_dump($c);
复制代码

输出:

  1. $a = array(
  2. 'a',
  3. );
  4. $b = array(
  5. 'u',
  6. );
  7. $c = array_merge_recursive($a, $b);
  8. var_dump($c);
复制代码

输出:

  1. $a = array(
  2. 'a',
  3. );
  4. $b = array(
  5. 'u',
  6. );
  7. $c = array_merge_recursive($a, $b);
  8. var_dump($c);
复制代码

输出:

  1. $a = array(
  2. 1=>'a',
  3. 2=>'b',
  4. 'c'=>'c',
  5. 'd'=>'d',
  6. );
  7. $b = array(
  8. 1=>'u',
  9. 3=>'v',
  10. 'c'=>'w',
  11. 'd'=>'x',
  12. 'y'=>'y',
  13. 60=>'z',
  14. );
  15. $c = array_merge_recursive($a, $b);
  16. var_dump($c);
复制代码

输出:

array(8) { [0]=> string(1) "a" [1]=> string(1) "b" ["c"]=> array(2) { [0]=> string(1) "c" [1]=> string(1) "w" } ["d"]=> array(2) { [0]=> string(1) "d" [1]=> string(1) "x" } [2]=> string(1) "u" [3]=> string(1) "v" ["y"]=> string(1) "y" [4]=> string(1) "z"}


09-19 07:17