Organizational Research By

Surprising Reserch Topic

Question:how to function cleans up empty arrays and fixes a bug in the first suggested version using php?



asked Sep 13, 2013 in PHP by rajesh
edited Sep 12, 2013
+1 vote
31 views



Related Hot Questions

1 Answer

0 votes

 

function array_diff_key_recursive ($a1, $a2) {
        foreach($a1 as $k => $v) {
            //$r[$k] = is_array($v) ? $this->array_diff_key_recursive($a1[$k], $a2[$k]) : array_diff_key($a1, $a2);
        if (is_array($v))
            {
            $r[$k]=$this->array_diff_key_recursive($a1[$k], $a2[$k]);
            }else
            {
            $r=array_diff_key($a1, $a2);
            }
 
        if (is_array($r[$k]) && count($r[$k])==0)
            {
            unset($r[$k]);
            }
        }
        return $r;
    }
?>
answered Sep 13, 2013 by rajesh
edited Sep 12, 2013

...