3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = ['p' => ['id' => TRUE]]; $b = ['p' => FALSE]; print "Behaves as expected.\n"; var_dump(array_merge_recursive($a, $b)); print "\n\nOMG internal array pointer shenanigans can affect the results of array_merge_recursive()!\n"; $a['p'][0] = 'SOMETHING, anything!'; unset($a['p'][0]); var_dump(array_merge_recursive($a, $b)); print "\n\nThis keeps happening…\n"; var_dump(array_merge_recursive($a, $b)); print "\n\n… not even resetting the internal array pointer helps …\n"; reset($a['p']); var_dump(array_merge_recursive($a, $b)); print "\n\n… nor casting to object, cloning, then back to array …\n"; $a['p'] = (array) clone (object) $a['p']; var_dump(array_merge_recursive($a, $b)); print "\n\n… only forcefully recreating a copy-by-value of the array by using array_slice().\n"; $a['p'] = array_slice($a['p'], 0); var_dump(array_merge_recursive($a, $b));
Output for git.master, git.master_jit, rfc.property-hooks
Behaves as expected. array(1) { ["p"]=> array(2) { ["id"]=> bool(true) [0]=> bool(false) } } OMG internal array pointer shenanigans can affect the results of array_merge_recursive()! array(1) { ["p"]=> array(2) { ["id"]=> bool(true) [1]=> bool(false) } } This keeps happening… array(1) { ["p"]=> array(2) { ["id"]=> bool(true) [1]=> bool(false) } } … not even resetting the internal array pointer helps … array(1) { ["p"]=> array(2) { ["id"]=> bool(true) [1]=> bool(false) } } … nor casting to object, cloning, then back to array … array(1) { ["p"]=> array(2) { ["id"]=> bool(true) [1]=> bool(false) } } … only forcefully recreating a copy-by-value of the array by using array_slice(). array(1) { ["p"]=> array(2) { ["id"]=> bool(true) [0]=> bool(false) } }

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:
146.11 ms | 408 KiB | 5 Q