mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Use symtable lookup for arrays in array_column
This commit is contained in:
parent
28801bf249
commit
d8590940a1
2 changed files with 24 additions and 1 deletions
|
@ -3534,7 +3534,7 @@ static inline zval *array_column_fetch_prop(zval *data, zval *name, zval *rv)
|
|||
}
|
||||
} else if (Z_TYPE_P(data) == IS_ARRAY) {
|
||||
if (Z_TYPE_P(name) == IS_STRING) {
|
||||
prop = zend_hash_find(Z_ARRVAL_P(data), Z_STR_P(name));
|
||||
prop = zend_symtable_find(Z_ARRVAL_P(data), Z_STR_P(name));
|
||||
} else if (Z_TYPE_P(name) == IS_LONG) {
|
||||
prop = zend_hash_index_find(Z_ARRVAL_P(data), Z_LVAL_P(name));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
--TEST--
|
||||
array_column() treats numeric string keys as usual
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
$array = [[42 => 'a'], [42 => 'b']];
|
||||
var_dump(array_column($array, 42));
|
||||
var_dump(array_column($array, "42"));
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
[1]=>
|
||||
string(1) "b"
|
||||
}
|
||||
array(2) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
[1]=>
|
||||
string(1) "b"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue