以下实例讲述了PHP实现查询两个数组中不同元素的方法。分享给大家供大家参考,具体如下:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
<?php $a = array (
"max_allow_dialogs" ,
"livechat_server_ip" ,
"livechat_service_time" ,
"abort_zh_cn" ,
"abort_zh_tw" ,
"abort_en_usa" ,
"welcome_zh_cn" ,
"welcome_zh_tw" ,
"welcome_en_usa" ,
"timeout_zh_cn" ,
"timeout_zh_tw" ,
"timeout_en_usa" ,
"absence_zh_cn" ,
"absence_zh_tw" ,
"absence_en_usa"
);
$b = array (
"max_allow_dialogs" ,
"livechat_server_ip" ,
"livechat_service_time" ,
"abort_zh_cn" ,
"abort_zh_tw" ,
"abort_en_usa" ,
"welcome_zh_cn" ,
"welcome_zh_tw" ,
"welcome_en_usa" ,
"timeout_zh_cn" ,
"timeout_zh_tw" ,
"timeout_en_usa" ,
);
$c = array_merge ( array_diff ( $a , $b ), array_diff ( $b , $a ));
print_r( $c );
?> |
结果:
Array
(
[0] => absence_zh_cn
[1] => absence_zh_tw
[2] => absence_en_usa
)