English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
PHP array_slice() function usage and example
Syntax
Definition and usage
Parameter | Serial number |
---|---|
1 | Parameter and description array (required) |
2 | It specifies an array. offset (required) |
3 | If offset is non-negative, the sequence will start from this offset in the array. If offset is negative, the sequence will start from a distance from the end of the array. length (optional) |
4 | If length is given and is positive, the sequence will have this many units. If length is given and negative, the sequence will terminate at a distance from the end of the array. If omitted, the sequence will start from offset to the end of the array. preserve_keys (optional) |
Return value
Online example
Example <?php print_r(array_slice($input, "", )); 2, -1$input = array("a", "b", "c", "d", "e"); print_r(array_slice($input, "", )); 2, -1, true)); ?>Test and see‹/›
Output result:
Array ( [0] => c [1=> d ) Array ( [2=> c [3=> d )