3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = ['a', 'b', 'c']; var_dump(array_slice($array, 0, 1)); // a print_r(array_slice($array, 1, 1)); // b print_r(array_slice($array, 2, 1)); // c print_r(array_slice($array, 3, 1)); // none print_r(array_slice($array, -1, 1)); // c print_r(array_slice($array, -2, 1)); // b print_r(array_slice($array, -3, 1)); // a print_r(array_slice($array, -4, 1)); // a !?
based on kBXGe
Output for 5.4.9 - 7.3.0beta1
array(1) { [0]=> string(1) "a" } Array ( [0] => b ) Array ( [0] => c ) Array ( ) Array ( [0] => c ) Array ( [0] => b ) Array ( [0] => a ) Array ( [0] => a )
Output for 5.3.19 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/AXJO0 on line 2
Process exited with code 255.