3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array( array("item_data"=>array(1,2,3)), array("item_data"=>array(4,5,6)), array("item_data"=>array(7,8,9)) ); function merge($prev, $now) { return array_merge($prev, $now['item_data']); } $res = array_reduce($arr, "merge"); var_dump($res);
based on Jm2s4
Output for 5.0.0 - 5.6.28, 7.0.0 - 7.1.0
Warning: array_merge(): Argument #1 is not an array in /in/QIQPO on line 6 Warning: array_merge(): Argument #1 is not an array in /in/QIQPO on line 6 Warning: array_merge(): Argument #1 is not an array in /in/QIQPO on line 6 NULL
Output for hhvm-3.10.0 - 3.13.2
Warning: array_merge() expects parameter 1 to be array, null given in /in/QIQPO on line 6 Warning: array_merge() expects parameter 1 to be array, null given in /in/QIQPO on line 6 Warning: array_merge() expects parameter 1 to be array, null given in /in/QIQPO on line 6 NULL
Output for 4.3.3 - 4.4.9
array(9) { [0]=> int(1) [1]=> int(2) [2]=> int(3) [3]=> int(4) [4]=> int(5) [5]=> int(6) [6]=> int(7) [7]=> int(8) [8]=> int(9) }
Output for 4.3.0 - 4.3.2
array(7) { ["item_data"]=> array(3) { [0]=> int(1) [1]=> int(2) [2]=> int(3) } [0]=> int(4) [1]=> int(5) [2]=> int(6) [3]=> int(7) [4]=> int(8) [5]=> int(9) }