note 64780 deleted from function.array-intersect-assoc by googleguy

From: Date: Tue, 22 Oct 2013 06:46:57 +0000
Subject: note 64780 deleted from function.array-intersect-assoc by googleguy
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-196638@lists.php.net to get a copy of this message
Note Submitter: asharm4 at ilstu dot edu ---- A function to find intersection of two arrays when comparison is based on only 1 key function array_common($array1,$array2,$compareString) { if (!is_array($array1) || !is_array($array2)) { return false; } $arrResult = array(); foreach ($array1 as $arrInsideArray1) { foreach ($array2 as $arrInsideArray2) { $found=false; if ($arrInsideArray1[$compareString]==$arrInsideArray2[$compareString]) { $found=true; break; } } if ($found) { array_push($arrResult,$arrInsideArray1); } } return $arrResult; }

« previous php.notes (#196638) next »