php - find duplicate value in multi-dimensional array -


from function given multidimensional array this:

array(     [0] => array(         [0] => 7,         [1] => 18     ),     [1] => array(         [0] => 12,         [1] => 7     ),     [2] => array(         [0] => 12,         [1] => 7,         [2] => 13     ) ) 

i need find duplicate values in 3 arrays within main array. example, if value 7 repeats in 3 arrays, return 7.

<?php $array = array(array(7,18), array(12,7), array(12, 7, 13)); $result = array();   $first = $array[0]; for($i=1; $i<count($array); $i++){  $result = array_intersect ($first, $array[$i]);  $first = $result; } print_r($result);//7 ?> 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -