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){ $i=0; return array_merge($prev,$now['class'][$i]); $i++; } $cc = array_reduce($all,"merge",array()); print_r($cc);
based on tWPV3
Output for 4.3.0 - 4.3.9, 5.0.0 - 5.0.2, 5.3.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.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 ( [0] => peter [1] => 15 [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/5AqbO on line 7
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 [1] => peter [2] => 15 [3] => male )