3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $k = (string)"0"; $a = array( 'name' => 'a', $k => 'null' ); $b = array( 'name' => 'b', $k => 'zero' ); $b = array( $k => 'zeronull', 'name' => 'b' ); var_dump($a); var_dump($b); var_dump($c); var_dump(array_merge($a, $b)); var_dump(array_merge($a, $c)); var_dump(array_merge($a, $b, $c));
Output for 5.0.4 - 5.6.28, 7.0.0 - 7.1.0
array(2) { ["name"]=> string(1) "a" [0]=> string(4) "null" } array(2) { [0]=> string(8) "zeronull" ["name"]=> string(1) "b" } Notice: Undefined variable: c in /in/WTr0J on line 10 NULL array(3) { ["name"]=> string(1) "b" [0]=> string(4) "null" [1]=> string(8) "zeronull" } Notice: Undefined variable: c in /in/WTr0J on line 12 Warning: array_merge(): Argument #2 is not an array in /in/WTr0J on line 12 NULL Notice: Undefined variable: c in /in/WTr0J on line 13 Warning: array_merge(): Argument #3 is not an array in /in/WTr0J on line 13 NULL
Output for hhvm-3.10.0 - 3.12.0
array(2) { ["name"]=> string(1) "a" [0]=> string(4) "null" } array(2) { [0]=> string(8) "zeronull" ["name"]=> string(1) "b" } Notice: Undefined variable: c in /in/WTr0J on line 10 NULL array(3) { ["name"]=> string(1) "b" [0]=> string(4) "null" [1]=> string(8) "zeronull" } Notice: Undefined variable: c in /in/WTr0J on line 12 Warning: Invalid operand type was used: expects array(s) in /in/WTr0J on line 12 NULL Notice: Undefined variable: c in /in/WTr0J on line 13 Warning: Invalid operand type was used: array_merge expects array(s) in /in/WTr0J on line 13 NULL
Output for 5.0.0 - 5.0.3
array(2) { ["name"]=> string(1) "a" [0]=> string(4) "null" } array(2) { [0]=> string(8) "zeronull" ["name"]=> string(1) "b" } Notice: Undefined variable: c in /in/WTr0J on line 10 NULL array(3) { ["name"]=> string(1) "b" [0]=> string(4) "null" [1]=> string(8) "zeronull" } Notice: Undefined variable: c in /in/WTr0J on line 12 Warning: array_merge(): Argument #2 is not an array in /in/WTr0J on line 12 NULL Notice: Undefined variable: c in /in/WTr0J on line 13 Warning: array_merge(): Argument #3 is not an array in /in/WTr0J on line 13 NULL
Output for 4.3.0 - 4.4.9
array(2) { ["name"]=> string(1) "a" [0]=> string(4) "null" } array(2) { [0]=> string(8) "zeronull" ["name"]=> string(1) "b" } Notice: Undefined variable: c in /in/WTr0J on line 10 NULL array(3) { ["name"]=> string(1) "b" [0]=> string(4) "null" [1]=> string(8) "zeronull" } Notice: Undefined variable: c in /in/WTr0J on line 12 array(2) { ["name"]=> string(1) "a" [0]=> string(4) "null" } Notice: Undefined variable: c in /in/WTr0J on line 13 array(3) { ["name"]=> string(1) "b" [0]=> string(4) "null" [1]=> string(8) "zeronull" }