JackDavis
JackDavis

Reputation: 127

PHP - combine multiple arrays (only occurrences of all arrays)

Is there any php function that can return occurrences of all provided arrays (that are in all arrays)?

Example:

$array1 = array(1, 2, 3);
$array2 = array(1, 2, 4, 5, 6);
$array3 = array(1, 2, 3, 4, 5);

func_i_am_looking_for($array1, $array2, $array3);
//retrun array(1, 2);

Upvotes: 0

Views: 24

Answers (1)

hsz
hsz

Reputation: 152216

Just try with array_intersect

$result = array_intersect($array1, $array2, $array3);

Upvotes: 3

Related Questions