Return duplicate values in arrays

6

My question is the following? I have the following array:

$array1 = array(10, 50, 80, 40, 90);
$array2 = array(10, 30, 10, 40, 20);
$array3 = array(10, 60, 15, 40, 30);
$array4 = array(20, 30, 40, 10, 50);
$array5 = array(10, 05, 10, 90, 40);

I would like to know if there is a simple way to go through all and return only the values that are repeated in all arrays.

To get duplicate values from the same array I am using:

$unArray = array_unique( array_diff_assoc( $idCliArray, array_unique( $idCliArray ) ) )

Now I need to know how to take only what is repeated at all.

    
asked by anonymous 29.08.2016 / 19:57

1 answer

6

You can use the array_intersect function, for example:

$array1 = array(10, 50, 80, 40, 90);
$array2 = array(10, 30, 10, 40, 20);
$array3 = array(10, 60, 15, 40, 30);
$array4 = array(20, 30, 40, 10, 50);
$array5 = array(10, 05, 10, 90, 40);

$values = array_intersect($array1,$array2,$array3,$array4,$array5);

IDEONE

    
29.08.2016 / 20:01