xref: /PHP-7.3/ext/standard/tests/array/bug68553.phpt (revision 782352c5)
1--TEST--
2Bug #68553 (array_column: null values in $index_key become incrementing keys in result)
3--FILE--
4<?php
5$i = 100;
6/* increase the resource id to make test stable */
7while ($i--) {
8	$fd = fopen(__FILE__, "r");
9	fclose($fd);
10}
11$a = [
12	['a' => 10],
13	['a' => 20],
14	['a' => true],
15	['a' => false],
16	['a' => fopen(__FILE__, "r")],
17	['a' => -5],
18	['a' => 7.38],
19	['a' => null, "test"],
20	['a' => null],
21];
22
23var_dump(array_column($a, null, 'a'));
24--EXPECTF--
25array(8) {
26  [10]=>
27  array(1) {
28    ["a"]=>
29    int(10)
30  }
31  [20]=>
32  array(1) {
33    ["a"]=>
34    int(20)
35  }
36  [1]=>
37  array(1) {
38    ["a"]=>
39    bool(true)
40  }
41  [0]=>
42  array(1) {
43    ["a"]=>
44    bool(false)
45  }
46  [%d]=>
47  array(1) {
48    ["a"]=>
49    resource(%d) of type (stream)
50  }
51  [-5]=>
52  array(1) {
53    ["a"]=>
54    int(-5)
55  }
56  [7]=>
57  array(1) {
58    ["a"]=>
59    float(7.38)
60  }
61  [""]=>
62  array(1) {
63    ["a"]=>
64    NULL
65  }
66}
67