blob: 17e7bdd48bf1c9f39af3a22e26c9c1cec9b971d9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
--TEST--
Test array_values() function : usage variations - multi-dimensional arrays
--FILE--
<?php
/*
* Test array_values when:
* 1. Passed a two-dimensional array as $input argument
* 2. Passed a sub-array as $input argument
* 3. Passed an infinitely recursive multi-dimensional array
*/
echo "*** Testing array_values() : usage variations ***\n";
$input = array ('zero' => 'zero', 'un' => 'one', 'sub' => array (1, 2, 3));
echo "\n-- Array values of a two-dimensional array --\n";
var_dump(array_values($input));
echo "\n-- Array values of a sub-array --\n";
var_dump(array_values($input['sub']));
// get an infinitely recursive array
$input[] = &$input;
echo "\n-- Array values of an infinitely recursive array --\n";
var_dump(array_values($input));
echo "Done";
?>
--EXPECT--
*** Testing array_values() : usage variations ***
-- Array values of a two-dimensional array --
array(3) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
}
-- Array values of a sub-array --
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
-- Array values of an infinitely recursive array --
array(4) {
[0]=>
string(4) "zero"
[1]=>
string(3) "one"
[2]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[3]=>
&array(4) {
["zero"]=>
string(4) "zero"
["un"]=>
string(3) "one"
["sub"]=>
array(3) {
[0]=>
int(1)
[1]=>
int(2)
[2]=>
int(3)
}
[0]=>
*RECURSION*
}
}
Done
|