Voting

: min(three, three)?
(Example: nine)

The Note You're Voting On

spark dot crz at gmail dot com
7 years ago
Yet another recursive implementation, without if-else hell and with multiple parameters just like the original.

<?php
function recursiveDiff() {
$arrs = func_get_args();
$diff = call_user_func_array('array_diff_assoc', $arrs);

foreach(
$diff as $key => $value) {
if (!
is_array($value))
continue;

$children = array_map(function($arr) use($key){
return
$arr[$key];
},
$arrs);

$diff[$key] = call_user_func_array(__FUNCTION__, $children);
}

return
$diff;
}

<< Back to user notes page

To Top