php - recursive array_diff()? -


i'm looking tool give me recursive diff of 2 arrays. envision web page 2 color-coded tree-structures. on each tree, green parts of array match in both arrays, , red parts of each don't match other. output of dbug

i have code gives me nested array populate report. i'm developing new method should faster, need test values , structure, make sure gives output identical old method.

is there out there can use? or need write this? or there way accomplish goals?

there 1 such function implemented in comments of array_diff.

function arrayrecursivediff($aarray1, $aarray2) {   $areturn = array();    foreach ($aarray1 $mkey => $mvalue) {     if (array_key_exists($mkey, $aarray2)) {       if (is_array($mvalue)) {         $arecursivediff = arrayrecursivediff($mvalue, $aarray2[$mkey]);         if (count($arecursivediff)) { $areturn[$mkey] = $arecursivediff; }       } else {         if ($mvalue != $aarray2[$mkey]) {           $areturn[$mkey] = $mvalue;         }       }     } else {       $areturn[$mkey] = $mvalue;     }   }   return $areturn; }  

the implementation handles 2 arrays @ time, not think posses problem. run diff sequentially if need diff of 3 or more arrays @ time. method uses key checks , loose verification.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -