Embed URL

HTTPS clone URL

SSH clone URL

You can clone with HTTPS or SSH.

Download Gist
View array_intersect_assoc_recursive.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
function array_intersect_assoc_recursive($arr1, $arr2) {
if (!is_array($arr1) || !is_array($arr2)) {
if($arr1 === $arr2) {
return $arr1;
} else {
return null;
}
}
$commonkeys = array_intersect(array_keys($arr1), array_keys($arr2));
$ret = array();
foreach ($commonkeys as $key) {
$val = array_intersect_assoc_recursive($arr1[$key], $arr2[$key]);
if(null !== $val) {
$ret[$key] = $val;
}
}
return $ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.