array_intersect question

From: Date: Tue, 02 Dec 2008 09:24:25 +0000
Subject: array_intersect question
Groups: php.general 
Request: Send a blank email to php-general+get-283979@lists.php.net to get a copy of this message
Dear all, I have to perform an intersection on array of arrays. The fact is that php does not support intersection on multidimensional arrays. So, the first simple example using only one dimensional arrays works well: $array1 = array("green", "red", "blue"); $array2 = array("green", "yellow", "red"); $array3 = array("green", "red", "purple"); $array4 = array("green","red","yellow"); $result = array_intersect($array1,$array2,$array3,$array4); print_r($result); And the result is: Array ( [0] => green [1] => red ) The question is how to perform intersection on the following structure: $products = array(array("green","red","blue"),array("green","yellow","red"),array("green","red","purple"),array("green","red","yellow")); Thanks in advance for any suggestions. Best, Andrej

« previous php.general (#283979) next »