``` $arr1=array('a_b','c_d','b_a','d_c'); ``` ``` $arr2=array('a_b','c_d','b_a','d_c'); ``` 条件: a_b==b_a; c_d==d_c; 需求:想得到无重复的数组: ``` $newArr=array('a_b','a_c'); ``` 解法: ``` $newArr=array(); foreach($arr2 as $key=>$value){ $ceilArr=explode("_",$value); $str=$ceilArr[1].'_'.$ceilArr[0]; if( in_array("$value",$arr1) && in_array("$str",$arr1) ){ //echo array_search("$str",$arr1);echo '
'; $newArr[]=$value; unset($arr1[array_search("$value",$arr1)]); unset($arr1[array_search("$str",$arr1)]); } } echo '
';
print_r($newArr);
echo count($newArr);
```





The end