3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function array_diff_assoc_recursive($array1, $array2) { $difference=array(); foreach($array1 as $key => $value) { if( is_array($value) ) { if( !isset($array2[$key]) || !is_array($array2[$key]) ) { $difference[$key] = $value; } else { $new_diff = array_diff_assoc_recursive($value, $array2[$key]); if( !empty($new_diff) ) $difference[$key] = $new_diff; } } else if( !array_key_exists($key,$array2) || $array2[$key] !== $value ) { $difference[$key] = $value; } } return $difference; } $a1=array( 'a' => 0, 'b' => null, 'c' => array( 'd' => null ) ); $a2=array( 'a' => 0, 'b' => null ); var_dump( array_diff_assoc_recursive( $a1, $a2 ) ); ?>
Output for 4.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
array(1) { ["c"]=> array(1) { ["d"]=> NULL } }