1--TEST--
2Test array_slice() function : basic functionality
3--FILE--
4<?php
5/* Prototype  : array array_slice(array $input, int $offset [, int $length [, bool $preserve_keys]])
6 * Description: Returns elements specified by offset and length
7 * Source code: ext/standard/array.c
8 */
9
10/*
11 * Test basic functionality of array_slice()
12 */
13
14echo "*** Testing array_slice() : basic functionality ***\n";
15
16
17$input = array('one' => 1, 'two' => 2, 3, 23 => 4);
18$offset = 2;
19$length = 2;
20$preserve_keys = true;
21
22// Calling array_slice() with all possible arguments
23echo "\n-- All arguments --\n";
24var_dump( array_slice($input, $offset, $length, $preserve_keys) );
25
26// Calling array_slice() with mandatory arguments
27echo "\n-- Mandatory arguments --\n";
28var_dump( array_slice($input, $offset) );
29
30echo "Done";
31?>
32--EXPECTF--
33*** Testing array_slice() : basic functionality ***
34
35-- All arguments --
36array(2) {
37  [0]=>
38  int(3)
39  [23]=>
40  int(4)
41}
42
43-- Mandatory arguments --
44array(2) {
45  [0]=>
46  int(3)
47  [1]=>
48  int(4)
49}
50Done
51