1--TEST--
2Test array_slice() function : usage variations - referenced variables
3--FILE--
4<?php
5/*
6 * Test array_slice() when:
7 * 1. Passed an array of referenced variables
8 * 2. $input argument is passed by reference
9 */
10
11echo "*** Testing array_slice() : usage variations ***\n";
12
13$val1 = 'one';
14$val2 = 'two';
15$val3 = 'three';
16
17echo "\n-- Array of referenced variables (\$preserve_keys = default) --\n";
18$input = array(3 => &$val1, 2 => &$val2, 1 => &$val3);
19var_dump(array_slice($input, 1, 2));
20
21echo "-- Change \$val2 (\$preserve_keys = TRUE) --\n";
22$val2 = 'hello, world';
23var_dump(array_slice($input, 1, 2, true));
24
25echo "Done";
26?>
27--EXPECT--
28*** Testing array_slice() : usage variations ***
29
30-- Array of referenced variables ($preserve_keys = default) --
31array(2) {
32  [0]=>
33  &string(3) "two"
34  [1]=>
35  &string(5) "three"
36}
37-- Change $val2 ($preserve_keys = TRUE) --
38array(2) {
39  [2]=>
40  &string(12) "hello, world"
41  [1]=>
42  &string(5) "three"
43}
44Done
45