3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $all = array(array("class"=>array(array("peter","15","male"),array("mary","24","female"),array("jason","22","male")))); print_r($all); function merge($prev,$now){ return array_merge($prev,$now); } $cc = array_reduce($all,"merge",array()); print_r($cc);
based on Xve2U
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.2, 5.3.0 - 7.1.0
Array ( [0] => Array ( [class] => Array ( [0] => Array ( [0] => peter [1] => 15 [2] => male ) [1] => Array ( [0] => mary [1] => 24 [2] => female ) [2] => Array ( [0] => jason [1] => 22 [2] => male ) ) ) ) Array ( [class] => Array ( [0] => Array ( [0] => peter [1] => 15 [2] => male ) [1] => Array ( [0] => mary [1] => 24 [2] => female ) [2] => Array ( [0] => jason [1] => 22 [2] => male ) ) )
Output for 5.0.3 - 5.2.17
Array ( [0] => Array ( [class] => Array ( [0] => Array ( [0] => peter [1] => 15 [2] => male ) [1] => Array ( [0] => mary [1] => 24 [2] => female ) [2] => Array ( [0] => jason [1] => 22 [2] => male ) ) ) ) Warning: array_merge(): Argument #1 is not an array in /in/cGWcC on line 6
Output for 4.3.10 - 4.4.9
Array ( [0] => Array ( [class] => Array ( [0] => Array ( [0] => peter [1] => 15 [2] => male ) [1] => Array ( [0] => mary [1] => 24 [2] => female ) [2] => Array ( [0] => jason [1] => 22 [2] => male ) ) ) ) Array ( [0] => 0 [class] => Array ( [0] => Array ( [0] => peter [1] => 15 [2] => male ) [1] => Array ( [0] => mary [1] => 24 [2] => female ) [2] => Array ( [0] => jason [1] => 22 [2] => male ) ) )