PHP merges two arrays. In particular, the + operator, which means that the array unit on the right (deduplication) is appended to the back of the array on the left. Copy the code as follows :? In the first case of phpechorn, rn; $ aa, especially the + operator, means that the array unit on the right (deduplication) is appended to the back of the array on the left.
The code is as follows:
Echo "\ r \ n first case \ r \ n ";
$ A = array (1, 2, 3, 4, 5, 6 );
$ B = array (7,8, 9 );
$ C = array_merge ($ a, $ B );
Print_r ($ c );
$ C = $ a + $ B;
Print_r ($ c );
$ C = $ B + $;
Print_r ($ c );
Echo "\ r \ n case 2 \ r \ n ";
$ A = array ('A', 'B', 'C', 'D', 'e', 'F ');
$ B = array ('A', 'X', 'y ');
$ C = array_merge ($ a, $ B );
Print_r ($ c );
$ C = $ a + $ B;
Print_r ($ c );
$ C = $ B + $;
Print_r ($ c );
Echo "\ r \ n case 3 \ r \ n ";
$ A = array (
1 => 'A ',
2 => 'B ',
3 => 'C ',
4 => 'D ',
5 => 'e ',
6 => 'F ');
$ B = array (
1 => 'A ',
7 => 'X ',
8 => 'y ');
$ C = array_merge ($ a, $ B );
Print_r ($ c );
$ C = $ a + $ B;
Print_r ($ c );
$ C = $ B + $;
Print_r ($ c );
?>
The result is as follows:
The code is as follows:
First case
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
[6] => 7
[7] => 8
[8] => 9
)
Array
(
[0] => 1
[1] => 2
[2] => 3
[3] => 4
[4] => 5
[5] => 6
)
Array
(
[0] => 7
[1] => 8
[2] => 9
[3] => 4
[4] => 5
[5] => 6
)
Case 2
Array
(
[0] =>
[1] => B
[2] => c
[3] => d
[4] => e
[5] => f
[6] =>
[7] => x
[8] => y
)
Array
(
[0] =>
[1] => B
[2] => c
[3] => d
[4] => e
[5] => f
)
Array
(
[0] =>
[1] => x
[2] => y
[3] => d
[4] => e
[5] => f
)
Case 3
Array
(
[0] =>
[1] => B
[2] => c
[3] => d
[4] => e
[5] => f
[6] =>
[7] => x
[8] => y
)
Array
(
[1] =>
[2] => B
[3] => c
[4] => d
[5] => e
[6] => f
[7] => x
[8] => y
)
Array
(
[1] =>
[7] => x
[8] => y
[2] => B
[3] => c
[4] => d
[5] => e
[6] => f
)
Distinct is appended to the back of the array on the left. The code is as follows :? Php echo "\ r \ n first case \ r \ n"; $ a =...