note 39822 added to function.array-intersect-assoc
| From: | nleippe at integr8ted dot com | Date: | Wed, 11 Feb 2004 21:46:12 +0000 |
| Subject: | note 39822 added to function.array-intersect-assoc | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65026@lists.php.net to get a copy of this message | ||
In response to the first posting below, try this:
function &array_intersect_assoc_recursive(&$arr1, &$arr2) {
if (!is_array($arr1) || !is_array($arr2)) {
return $arr1 == $arr2; // or === for strict type
}
$commonkeys = array_intersect(array_keys($arr1), array_keys($arr2));
$ret = array();
foreach ($commonkeys as $key) {
$ret[$key] =& array_intersect_assoc_recursive($arr1[$key], $arr2[$key]);
}
return $ret;
}
----
Manual Page -- http://www.php.net/manual/en/function.array-intersect-assoc.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39822
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39822&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39822&report=yes
Search -- http://master.php.net/manage/user-notes.php