3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_diff_assoc_recursive($array1, $array2) { foreach($array1 as $key => $value) { if(is_array($value)) { if(!isset($array2[$key])) { $difference[$key] = $value; } elseif(!is_array($array2[$key])) { $difference[$key] = $value; } else { $new_diff = array_diff_assoc_recursive($value, $array2[$key]); if($new_diff != FALSE) { $difference[$key] = $new_diff; } } } elseif(!isset($array2[$key]) || $array2[$key] != $value) { $difference[$key] = $value; } } return !isset($difference) ? 0 : $difference; } $result = array_diff_assoc_recursive(array('a' => array('b' => 'x')), array('a' => array('c' => 'x'))); var_dump($result); $result = array_diff_assoc(array('a' => array('b' => 'x')), array('a' => array('c' => 'x'))); var_dump($result);
Output for git.master, git.master_jit, rfc.property-hooks
array(1) { ["a"]=> array(1) { ["b"]=> string(1) "x" } } Warning: Array to string conversion in /in/f05nC on line 37 Warning: Array to string conversion in /in/f05nC on line 37 array(0) { }

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
33.64 ms | 401 KiB | 8 Q