php - Array duplicated how to make a single -


this question has answer here:

i have example var $test , output below. can see duplicated. how can make not duplicated? there function it?

array (         [title] => array (               [0] => field required               [1] => must longer than2         )         [subtitle] => array (               [0] => field required               [1] => must longer than2         )  )     array (         [title] => array (               [0] => field required               [1] => must longer than2         )         [subtitle] => array (               [0] => field required               [1] => must longer than2         )  )     

expected result:

array (         [title] => array (               [0] => field required               [1] => must longer than2         )         [subtitle] => array (               [0] => field required               [1] => must longer than2         )  )     

function intersect($data=null){       if(!empty($data)){$crashed = array();       $crashed2 = array();       foreach($data[0] $key=>$val){               if(!is_array($val)){                $crashed[$key] = in_array($val,$data[1]);//return true if crashed(intersect)               }else{                $crashed2[$key] = intersect(array($val,$data[1]));               }       $crashed = array_merge($crashed,$crashed2);        }     }return $crashed;    }    $intersect =intersect(array($array1,$array2));    print_r($intersect); 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -