3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a1 = array('params' => array('width' => 500, 'height' => 200), 'oembed' => true, 'other' => '300'); $a2 = array('params' => array('height' => 100), 'oembed' => false); $expected = array('params' => array('width' => 500, 'height' => 100), 'oembed' => false, 'other' => '300'); var_dump(($expected === array_replace_recursive($a1, $a2))); $a1 = array('params' => array('width' => 500, 'height' => 200), 'oembed' => true, 'other' => '300'); $a2 = array(); $expected = $a1; var_dump(($expected === array_replace_recursive($a1, $a2))); $a1 = array('params' =>array('width' => 500, 'height' => 200), 'oembed' => true, 'other' => '300'); $a2 = array('params' =>array('width' => 100, 'stuff' => 888), 'oembed' => false); $expected = array('params' => array('width' => 100, 'height' => 200, 'stuff' => 888), 'oembed' => false, 'other' => '300'); var_dump(($expected === array_replace_recursive($a1, $a2))); $a1 = array('params' => array('width' => 500, 'height' => 200), 'oembed' => true, 'other' => '300'); $a2 = array('params' => array(), 'oembed' => true); $expected = array('params' => array('width' => 500, 'height' => 200), 'oembed' => true, 'other' => '300'); var_dump(($expected === array_replace_recursive($a1, $a2)));

preferences:
36.91 ms | 402 KiB | 5 Q