3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $struct = [ 'username' => '', 'password' => '', 'someId' => 1, ]; $input = [ 'username' => '', 'password' => '', 'someId' => 1, ]; var_dump(array_merge_recursive($input, $struct)); var_dump(array_diff(array_merge_recursive($input, $struct), $struct));
based on HtvkD
Output for 7.0.0 - 7.2.0
array(3) { ["username"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["password"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["someId"]=> array(2) { [0]=> int(1) [1]=> int(1) } } Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 array(3) { ["username"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["password"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["someId"]=> array(2) { [0]=> int(1) [1]=> int(1) } }
Output for 5.4.12 - 5.6.28
array(3) { ["username"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["password"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["someId"]=> array(2) { [0]=> int(1) [1]=> int(1) } } Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 Notice: Array to string conversion in /in/1g4cN on line 17 array(3) { ["username"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["password"]=> array(2) { [0]=> string(0) "" [1]=> string(0) "" } ["someId"]=> array(2) { [0]=> int(1) [1]=> int(1) } }
Output for 5.3.22 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/1g4cN on line 3
Process exited with code 255.