二维数级差集
$A = [ ["sbnumber" => "0513-0001-00001", "name" => "心安苑"], ["sbnumber" => "0513-0001-00002", "name" => "中正苑"], ["sbnumber" => "0513-0001-00003", "name" => "务实苑"], ["sbnumber" => "0513-0001-00004", "name" => "服务苑"], ["sbnumber" => "0513-0001-00007", "name" => "李四7"] ]; $B = [ ["sbnumber" => "0513-0001-00001", "name" => "心安苑"], ["sbnumber" => "0513-0001-00002", "name" => "中正苑"], ["sbnumber" => "0513-0001-00003", "name" => "务实苑"], ["sbnumber" => "0513-0001-00004", "name" => "服务苑"], ["sbnumber" => "0513-0001-00007", "name" => "李四"] ]; $C = array(); foreach($A as $a){ $Ck = $a['sbnumber'].'#'.$a['name']; $C[$Ck] = 1; } $D = array(); foreach($B as $b){ $Dk = $b['sbnumber'].'#'.$b['name']; $D[$Dk] = 1; } /* * A - B */ $A_B = array(); foreach($C as $key => $val){ if(isset($D[$key])&&$D[$key]==1){ }else{ $A_B[] = explode('#', $key); } } echo '<br/>'; /* * B-A */ $B_A = array(); foreach($D as $key=>$val){ if(isset($C[$key])&&$C[$key]==1){ }else{ $B_A[] = explode('#', $key); } } dump($B_A);