note 43568 deleted from function.array-intersect by nlopess

From: Date: Sat, 26 Jun 2004 16:42:18 +0000
Subject: note 43568 deleted from function.array-intersect by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-71788@lists.php.net to get a copy of this message
Note Submitter: monte@ispi.net ---- I couldn't find any array union functionality in PHP (extracting the common elements between two arrays), so the best method I could think of was to intersect them from both directions: $arr1 = array(1,2,3,4); $arr2 = array(2,4,6,8); $union = array_intersect($arr2, array_intersect($arr1, $arr2)); print_r($union); output: Array ( [0] => 2 [1] => 4 ) This result is the union of the two arrays.

« previous php.notes (#71788) next »