3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $array1 = array(1,2,3,4,5,6,7,8); $originalArray = $array1; $array2 = array('a','b','c','d','e','f','g'); $n = count($array1); for($x = 0; $x < $n; $x++) { array_splice($array1, 1, -$x); print_r ($array1); $array1 = $originalArray; }
Output for 4.3.0 - 5.6.28, hhvm-3.12.0, 7.0.0 - 7.1.0
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 ) Array ( [0] => 1 [1] => 8 ) Array ( [0] => 1 [1] => 7 [2] => 8 ) Array ( [0] => 1 [1] => 6 [2] => 7 [3] => 8 ) Array ( [0] => 1 [1] => 5 [2] => 6 [3] => 7 [4] => 8 ) Array ( [0] => 1 [1] => 4 [2] => 5 [3] => 6 [4] => 7 [5] => 8 ) Array ( [0] => 1 [1] => 3 [2] => 4 [3] => 5 [4] => 6 [5] => 7 [6] => 8 ) Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 )
Output for hhvm-3.10.0

Process exited with code 153.