3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $stack = range('a', 'h'); print_r($stack); $stack = array_slice($stack, 0, -4); print_r($stack); $stack[] = 'wew'; print_r($stack); echo "===========================================================\n"; $stack = range('a', 'h'); print_r($stack); $stack = array_slice($stack, 0, -4, FALSE); print_r($stack); $stack[] = 'wew'; print_r($stack); echo "===========================================================\n"; $stack = range('a', 'h'); print_r($stack); $stack = array_slice($stack, 0, -4, TRUE); print_r($stack); $stack[] = 'wew'; print_r($stack); echo "===========================================================\n";
based on LNEm3
Output for 5.0.2 - 7.2.0
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f [6] => g [7] => h ) Array ( [0] => a [1] => b [2] => c [3] => d ) Array ( [0] => a [1] => b [2] => c [3] => d [4] => wew ) =========================================================== Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f [6] => g [7] => h ) Array ( [0] => a [1] => b [2] => c [3] => d ) Array ( [0] => a [1] => b [2] => c [3] => d [4] => wew ) =========================================================== Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f [6] => g [7] => h ) Array ( [0] => a [1] => b [2] => c [3] => d ) Array ( [0] => a [1] => b [2] => c [3] => d [4] => wew ) ===========================================================
Output for 4.3.0 - 5.0.1
Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f [6] => g [7] => h ) Array ( [0] => a [1] => b [2] => c [3] => d ) Array ( [0] => a [1] => b [2] => c [3] => d [4] => wew ) =========================================================== Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f [6] => g [7] => h ) Warning: Wrong parameter count for array_slice() in /in/f7CSt on line 11 Array ( [0] => wew ) =========================================================== Array ( [0] => a [1] => b [2] => c [3] => d [4] => e [5] => f [6] => g [7] => h ) Warning: Wrong parameter count for array_slice() in /in/f7CSt on line 18 Array ( [0] => wew ) ===========================================================