if(!empty($ids)){
//对关系表进行处理 foreach ($binding_tags as $key => $val) { $arr_past[] = $val['id']; } $arr_now = explode(",",$ids); $len = count($arr_now)-1; $ids_now = array_slice($arr_now,0,$len);//最终的需要绑定的标签id数组 //对数组做比较 print_r($arr_past); print_r($ids_now); //$arr_final = array_diff_assoc($arr_past,$ids_now); $arr_final = array_merge(array_diff($arr_past,$ids_now),array_diff($ids_now,$arr_past)); //关键 print_r($arr_final ); }