<?PHP//This class is automatically generated by the system and is intended for testing purposes onlyclassIndexactionextendsAction {//Raw Data /*Array ([0] = = Array ([AP] = [AC] = 569418) [1] = = Array ([AP] = [AC] = 569520) [2] = = Array ([ap] = [AC] = 569533))*///data after duplicate values are removed/*Array ([P] = Array ([AP] = [AC] = 569418))*/ Public functionindex () {$arr=Array(); $arr=Array(' 0 ' + =Array(' ap ' = ' + ', ' ac ' = ' 569418 '), ' 1 ' + =Array(' ap ' = ' + ', ' ac ' = ' 569520 '), ' 2 ' + =Array(' ap ' = ' + ', ' ac ' = ' 569533 ')); Print_r($arr); $key= ' ap '; $arr=$this->array_unset ($arr,$key); Print_r($arr); //$this->display (); } //Two-dimensional arrays remove duplicates of specific keys Public functionArray_unset ($arr,$key){//the key value of the passed-in array $key, $arr//Set up a target array $res=Array(); foreach(Array_reverse($arr) as $value){//array_reverse () PHP array order reversal if(isset($res[$value[$key]])){//See if there are duplicates unset($value[$key]);//There: Destruction}Else{ $res[$value[$key]] =$value; } } return $res; }}?>
Two-dimensional arrays remove duplicates of specific keys