3v4l.org

run code in 300+ PHP versions simultaneously
<?php function array_thingy(array $a, array $b) { $result = array(); $longest = max(count($a), count($b)); for ($i=0; $i < $longest; $i++) { if (isset($a[$i])) $result[] = $a[$i]; if (isset($b[$i])) $result[] = $b[$i]; } return $result; } $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.1.6, 5.2.0 - 5.2.17, 5.3.0 - 5.3.29, 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
array(7) { [0]=> array(2) { ["name"]=> string(9) "Product 1" ["type"]=> string(1) "p" } [1]=> array(2) { ["name"]=> string(8) "social 1" ["type"]=> string(1) "f" } [2]=> array(2) { ["name"]=> string(9) "Product 2" ["type"]=> string(1) "p" } [3]=> array(2) { ["name"]=> string(8) "social 2" ["type"]=> string(1) "f" } [4]=> array(2) { ["name"]=> string(8) "social 3" ["type"]=> string(1) "f" } [5]=> array(2) { ["name"]=> string(8) "social 4" ["type"]=> string(1) "f" } [6]=> array(2) { ["name"]=> string(8) "social 5" ["type"]=> string(1) "f" } }
Output for 5.0.0 - 5.0.5
Parse error: parse error, unexpected T_ARRAY, expecting '&' or T_VARIABLE in /in/HcUQi 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/HcUQi on line 3
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.3.11, 4.4.0 - 4.4.1
Parse error: parse error, unexpected T_ARRAY, expecting ')' in /in/HcUQi on line 3
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error, expecting `')'' in /in/HcUQi on line 3
Process exited with code 255.

preferences:
296.45 ms | 401 KiB | 455 Q