3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array1 = array(1,2,3,4,5,6,7,8); $array2 = array('a','b','c','d','e','f','g'); $n = count($array1); for($x = 0; $x < $n; $x++) { array_splice($array1, 1, $x, $array2); print_r ($array1); }
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => 2 [9] => 3 [10] => 4 [11] => 5 [12] => 6 [13] => 7 [14] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => b [9] => c [10] => d [11] => e [12] => f [13] => g [14] => 2 [15] => 3 [16] => 4 [17] => 5 [18] => 6 [19] => 7 [20] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => c [9] => d [10] => e [11] => f [12] => g [13] => b [14] => c [15] => d [16] => e [17] => f [18] => g [19] => 2 [20] => 3 [21] => 4 [22] => 5 [23] => 6 [24] => 7 [25] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => d [9] => e [10] => f [11] => g [12] => c [13] => d [14] => e [15] => f [16] => g [17] => b [18] => c [19] => d [20] => e [21] => f [22] => g [23] => 2 [24] => 3 [25] => 4 [26] => 5 [27] => 6 [28] => 7 [29] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => e [9] => f [10] => g [11] => d [12] => e [13] => f [14] => g [15] => c [16] => d [17] => e [18] => f [19] => g [20] => b [21] => c [22] => d [23] => e [24] => f [25] => g [26] => 2 [27] => 3 [28] => 4 [29] => 5 [30] => 6 [31] => 7 [32] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => f [9] => g [10] => e [11] => f [12] => g [13] => d [14] => e [15] => f [16] => g [17] => c [18] => d [19] => e [20] => f [21] => g [22] => b [23] => c [24] => d [25] => e [26] => f [27] => g [28] => 2 [29] => 3 [30] => 4 [31] => 5 [32] => 6 [33] => 7 [34] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => g [9] => f [10] => g [11] => e [12] => f [13] => g [14] => d [15] => e [16] => f [17] => g [18] => c [19] => d [20] => e [21] => f [22] => g [23] => b [24] => c [25] => d [26] => e [27] => f [28] => g [29] => 2 [30] => 3 [31] => 4 [32] => 5 [33] => 6 [34] => 7 [35] => 8 ) Array ( [0] => 1 [1] => a [2] => b [3] => c [4] => d [5] => e [6] => f [7] => g [8] => g [9] => f [10] => g [11] => e [12] => f [13] => g [14] => d [15] => e [16] => f [17] => g [18] => c [19] => d [20] => e [21] => f [22] => g [23] => b [24] => c [25] => d [26] => e [27] => f [28] => g [29] => 2 [30] => 3 [31] => 4 [32] => 5 [33] => 6 [34] => 7 [35] => 8 )
Output for hhvm-3.10.0

Process exited with code 153.