- $a = array(
- 'a',
- );
- $b = array(
- 'u',
- );
- $c = $a + $b;
- var_dump($c);
Copy code
Output:
- $a = array(
- 66=>'a',
- );
- $b = array(
- 60=>'u',
- 66=>'c'
- );
- $c = $a + $b;
- var_dump($c);
Copy code
Output:
-
$a = array(
- 1=>'a',
- 2=>'b',
- 'c'=>'c',
- 'd'= >'d',
- );
- $b = array(
- 1=>'u',
- 3=>'v',
- 'c'=>'w',
- 'd'=> ;'x',
- 'y'=>'y',
- 60=>'z',
- );
- $c = $a + $b;
- var_dump($c);
- ?>
Copy code
Output:
- $a = array(
- 'a',
- );
- $b = array(
- 'u',
- );
- $c = array_merge($a, $b);
- var_dump($ c);
Copy code
Output:
- $a = array(
- 66=>'a',
- );
- $b = array(
- 60=>'u',
- 66=>'c'
- );
- $c = array_merge($a, $b);
- var_dump($c);
Copy code
Output:
- $a = array(
- 1=>'a',
- 2=>'b',
- 'c'=>'c',
- 'd'=>'d' ,
- );
- $b = array(
- 1=>'u',
- 3=>'v',
- 'c'=>'w',
- 'd'=>'x',
- 'y'=>'y',
- 60=>'z',
- );
- $c = array_merge($a, $b);
- var_dump($c);
Copy code
Output:
- $a = array(
- 'a',
- );
- $b = array(
- 'u',
- );
- $c = array_merge_recursive($a, $b);
- var_dump($ c);
Copy code
Output:
- $a = array(
- 'a',
- );
- $b = array(
- 'u',
- );
- $c = array_merge_recursive($a, $b);
- var_dump($ c);
Copy code
Output:
- $a = array(
- 1=>'a',
- 2=>'b',
- 'c'=>'c',
- 'd'=>'d' ,
- );
- $b = array(
- 1=>'u',
- 3=>'v',
- 'c'=>'w',
- 'd'=>'x',
- 'y'=>'y',
- 60=>'z',
- );
- $c = array_merge_recursive($a, $b);
- var_dump($c);
Copy code
Output: 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" } |