note 64780 added to function.array-intersect-assoc
| From: | asharm4 at ilstu dot edu | Date: | Thu, 20 Apr 2006 16:20:23 +0000 |
| Subject: | note 64780 added to function.array-intersect-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-108823@lists.php.net to get a copy of this message | ||
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;
}
----
Server IP: 216.194.113.175
Probable Submitter: 71.113.141.16
----
X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER
autolearn=no version=2.64
----
Manual Page -- http://www.php.net/manual/en/function.array-intersect-assoc.php
Edit -- http://master.php.net/note/edit/64780
Del: integrated -- http://master.php.net/note/delete/64780/integrated
Del: useless -- http://master.php.net/note/delete/64780/useless
Del: bad code -- http://master.php.net/note/delete/64780/bad+code
Del: spam -- http://master.php.net/note/delete/64780/spam
Del: non-english -- http://master.php.net/note/delete/64780/non-english
Del: in docs -- http://master.php.net/note/delete/64780/in+docs
Del: other reasons-- http://master.php.net/note/delete/64780
Reject -- http://master.php.net/note/reject/64780
Search -- http://master.php.net/manage/user-notes.php