forked from php/php-src
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharray_column_variant.phpt
85 lines (81 loc) · 1.83 KB
/
array_column_variant.phpt
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
--TEST--
Test array_column() function: variant functionality
--FILE--
<?php
/* Array from Bug Request #64493 test script */
$rows = array(
456 => array('id' => '3', 'title' => 'Foo', 'date' => '2013-03-25'),
457 => array('id' => '5', 'title' => 'Bar', 'date' => '2012-05-20'),
);
echo "-- pass null as second parameter to get back all columns indexed by third parameter --\n";
var_dump(array_column($rows, null, 'id'));
echo "-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns --\n";
var_dump(array_column($rows, null, 'foo'));
echo "-- pass null as second parameter and no third param to get back array_values(input) --\n";
var_dump(array_column($rows, null));
echo "Done\n";
--EXPECTF--
-- pass null as second parameter to get back all columns indexed by third parameter --
array(2) {
[3]=>
array(3) {
["id"]=>
string(1) "3"
["title"]=>
string(3) "Foo"
["date"]=>
string(10) "2013-03-25"
}
[5]=>
array(3) {
["id"]=>
string(1) "5"
["title"]=>
string(3) "Bar"
["date"]=>
string(10) "2012-05-20"
}
}
-- pass null as second parameter and bogus third param to get back zero-indexed array of all columns --
array(2) {
[0]=>
array(3) {
["id"]=>
string(1) "3"
["title"]=>
string(3) "Foo"
["date"]=>
string(10) "2013-03-25"
}
[1]=>
array(3) {
["id"]=>
string(1) "5"
["title"]=>
string(3) "Bar"
["date"]=>
string(10) "2012-05-20"
}
}
-- pass null as second parameter and no third param to get back array_values(input) --
array(2) {
[0]=>
array(3) {
["id"]=>
string(1) "3"
["title"]=>
string(3) "Foo"
["date"]=>
string(10) "2013-03-25"
}
[1]=>
array(3) {
["id"]=>
string(1) "5"
["title"]=>
string(3) "Bar"
["date"]=>
string(10) "2012-05-20"
}
}
Done