array_slice

PHP 4, PHP 5, PHP 7, PHP 8
array_slice - Extract a slice of the array

Example #1 array_slice examples

Result: Array ( [0] => c [1] => d ) Array ( [2] => c [3] => d )
PHP Version:

Example #2 array_slice and one-based array

Result: Array ( [0] => b [1] => c )
PHP Version:

Example #3 array_slice and array with mixed keys

Result: Array ( [a] => apple [b] => banana [0] => pear ) Array ( [a] => apple [b] => banana [42] => pear )
PHP Version:


Example #4 of array_slice

PHP Version: