1--TEST--
2Test array_slice() function : usage variations - pass different int values as $length arg
3--FILE--
4<?php
5/*
6 * Pass different integer values as $length argument to array_slice() to test behaviour
7 */
8
9echo "*** Testing array_slice() : usage variations ***\n";
10
11$input = array ('one' => 1, 2 => 'two', 'three', 9 => 'nine', 'ten' => 10);
12$offset = 1;
13
14for ($i = -6; $i <= 6; $i++) {
15    echo "\n-- \$length is $i --\n";
16    var_dump(array_slice($input, $offset, $i));
17}
18echo "\n-- \$length is maximum integer value --\n";
19var_dump(array_slice($input, $offset, PHP_INT_MAX));
20
21echo "\n-- \$length is minimum integer value --\n";
22var_dump(array_slice($input, $offset, -PHP_INT_MAX));
23
24echo "Done";
25?>
26--EXPECT--
27*** Testing array_slice() : usage variations ***
28
29-- $length is -6 --
30array(0) {
31}
32
33-- $length is -5 --
34array(0) {
35}
36
37-- $length is -4 --
38array(0) {
39}
40
41-- $length is -3 --
42array(1) {
43  [0]=>
44  string(3) "two"
45}
46
47-- $length is -2 --
48array(2) {
49  [0]=>
50  string(3) "two"
51  [1]=>
52  string(5) "three"
53}
54
55-- $length is -1 --
56array(3) {
57  [0]=>
58  string(3) "two"
59  [1]=>
60  string(5) "three"
61  [2]=>
62  string(4) "nine"
63}
64
65-- $length is 0 --
66array(0) {
67}
68
69-- $length is 1 --
70array(1) {
71  [0]=>
72  string(3) "two"
73}
74
75-- $length is 2 --
76array(2) {
77  [0]=>
78  string(3) "two"
79  [1]=>
80  string(5) "three"
81}
82
83-- $length is 3 --
84array(3) {
85  [0]=>
86  string(3) "two"
87  [1]=>
88  string(5) "three"
89  [2]=>
90  string(4) "nine"
91}
92
93-- $length is 4 --
94array(4) {
95  [0]=>
96  string(3) "two"
97  [1]=>
98  string(5) "three"
99  [2]=>
100  string(4) "nine"
101  ["ten"]=>
102  int(10)
103}
104
105-- $length is 5 --
106array(4) {
107  [0]=>
108  string(3) "two"
109  [1]=>
110  string(5) "three"
111  [2]=>
112  string(4) "nine"
113  ["ten"]=>
114  int(10)
115}
116
117-- $length is 6 --
118array(4) {
119  [0]=>
120  string(3) "two"
121  [1]=>
122  string(5) "three"
123  [2]=>
124  string(4) "nine"
125  ["ten"]=>
126  int(10)
127}
128
129-- $length is maximum integer value --
130array(4) {
131  [0]=>
132  string(3) "two"
133  [1]=>
134  string(5) "three"
135  [2]=>
136  string(4) "nine"
137  ["ten"]=>
138  int(10)
139}
140
141-- $length is minimum integer value --
142array(0) {
143}
144Done
145