3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = array(0,1,2,3,4,5,6,7,8,9); $maxtries = intval(count($a)*(floatval(count($a)+1)/2.0)); $tries = 0; while(!empty($a) && $tries<$maxtries) { echo "Try number: $tries\n"; print_r($a); array_push($a[$tries]); unset($a[$tries]); $tries += 1; } echo "done\n"; print_r($a);
based on 3OcSq
Output for 5.3.0 - 7.2.0
Try number: 0 Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 1 Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 2 Array ( [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 3 Array ( [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 4 Array ( [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 5 Array ( [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 6 Array ( [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 7 Array ( [7] => 7 [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 8 Array ( [8] => 8 [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 Try number: 9 Array ( [9] => 9 ) Warning: array_push() expects at least 2 parameters, 1 given in /in/6X1kb on line 10 done Array ( )
Output for 4.3.0 - 5.2.17
Try number: 0 Array ( [0] => 0 [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 1 Array ( [1] => 1 [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 2 Array ( [2] => 2 [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 3 Array ( [3] => 3 [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 4 Array ( [4] => 4 [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 5 Array ( [5] => 5 [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 6 Array ( [6] => 6 [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 7 Array ( [7] => 7 [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 8 Array ( [8] => 8 [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 Try number: 9 Array ( [9] => 9 ) Warning: Wrong parameter count for array_push() in /in/6X1kb on line 10 done Array ( )