1
2<?php
3$input = array("a", "b", "c", "d", "e");
4
5$output = array_slice($input, 2); // returns "c", "d", and "e"
6$output = array_slice($input, -2, 1); // returns "d"
7$output = array_slice($input, 0, 3); // returns "a", "b", and "c"
8
9// note the differences in the array keys
10print_r(array_slice($input, 2, -1));
11print_r(array_slice($input, 2, -1, true));
12?>
13/*
14Array
15(
16 [0] => c
17 [1] => d
18)
19Array
20(
21 [2] => c
22 [3] => d
23)
24*/
25