3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function array_thingy(array $a, array $b) { $output = array(); while (count($a) > 0 || count($b) > 0) { if (count($a) > 0) { array_push($output, array_shift($a)); } if (count($b) > 0) { array_push($output, array_shift($b)); } } } $a = array( array( 'name' => 'Product 1', 'type' => 'p' ), array( 'name' => 'Product 2', 'type' => 'p' ) ); $b = array( array( 'name' => 'social 1', 'type' => 'f' ), array( 'name' => 'social 2', 'type' => 'f' ), array( 'name' => 'social 3', 'type' => 'f' ), array( 'name' => 'social 4', 'type' => 'f' ), array( 'name' => 'social 5', 'type' => 'f' ) ); var_dump(array_thingy($a, $b));
Output for 5.1.0 - 5.6.28, hhvm-3.10.0 - 3.13.2, 7.0.0 - 7.1.0
NULL
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/pg5DJ on line 3
Process exited with code 255.
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_ARRAY, expecting ')' in /in/pg5DJ on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/pg5DJ on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/pg5DJ on line 3
Process exited with code 255.