1--TEST--
2Test array_values() function : usage variations - Referenced variables
3--INI--
4allow_call_time_pass_reference=on
5--FILE--
6<?php
7/* Prototype  : array array_values(array $input)
8 * Description: Return just the values from the input array
9 * Source code: ext/standard/array.c
10 */
11
12/*
13 * Test array_values() when:
14 * 1. Passed an array made up of referenced variables
15 * 2. Passed an array by reference
16 */
17
18echo "*** Testing array_values() : usage variations ***\n";
19
20$val1 = 'one';
21$val2 = 'two';
22$val3 = 'three';
23
24echo "\n-- \$input is an array made up of referenced variables: --\n";
25$input = array(&$val1, &$val2, &$val3);
26var_dump($result1 = array_values($input));
27
28echo "Change \$val2 and check result of array_values():\n";
29$val2 = 'deux';
30var_dump($result1);
31
32echo "\n-- Pass \$input argument by reference --\n";
33$array = array(1, 2, 3);
34var_dump($result2 = array_values(&$array));
35
36echo "Done";
37?>
38
39--EXPECTF--
40*** Testing array_values() : usage variations ***
41
42-- $input is an array made up of referenced variables: --
43array(3) {
44  [0]=>
45  &string(3) "one"
46  [1]=>
47  &string(3) "two"
48  [2]=>
49  &string(5) "three"
50}
51Change $val2 and check result of array_values():
52array(3) {
53  [0]=>
54  &string(3) "one"
55  [1]=>
56  &string(4) "deux"
57  [2]=>
58  &string(5) "three"
59}
60
61-- Pass $input argument by reference --
62array(3) {
63  [0]=>
64  int(1)
65  [1]=>
66  int(2)
67  [2]=>
68  int(3)
69}
70Done
71