Skip to content

Commit d859094

Browse files
committed
Use symtable lookup for arrays in array_column
1 parent 28801bf commit d859094

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

ext/standard/array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3534,7 +3534,7 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv)
35343534
}
35353535
} else if (Z_TYPE_P(data) == IS_ARRAY) {
35363536
if (Z_TYPE_P(name) == IS_STRING) {
3537-
prop = zend_hash_find(Z_ARRVAL_P(data), Z_STR_P(name));
3537+
prop = zend_symtable_find(Z_ARRVAL_P(data), Z_STR_P(name));
35383538
} else if (Z_TYPE_P(name) == IS_LONG) {
35393539
prop = zend_hash_index_find(Z_ARRVAL_P(data), Z_LVAL_P(name));
35403540
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
--TEST--
2+
array_column() treats numeric string keys as usual
3+
--FILE--
4+
<?php
5+
6+
$array = [[42 => 'a'], [42 => 'b']];
7+
var_dump(array_column($array, 42));
8+
var_dump(array_column($array, "42"));
9+
10+
?>
11+
--EXPECT--
12+
array(2) {
13+
[0]=>
14+
string(1) "a"
15+
[1]=>
16+
string(1) "b"
17+
}
18+
array(2) {
19+
[0]=>
20+
string(1) "a"
21+
[1]=>
22+
string(1) "b"
23+
}

0 commit comments

Comments
 (0)