From 4ebcb2ecfecc55967d96f0c911b92b980be1b284 Mon Sep 17 00:00:00 2001 From: Ilia Alshanetsky Date: Sun, 11 Jul 2004 15:23:57 +0000 Subject: [PATCH] Fixed bug #29008 (array_combine() does not handle non-numeric/string keys). --- NEWS | 2 ++ ext/standard/array.c | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/NEWS b/NEWS index 06cb0bc62c..fb39b2d25f 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,8 @@ PHP NEWS - Updated PCRE to provide better error handling in certain cases. (Andrei) - Changed doc comments to require a single white space after '/**'. (Marcus) - Fixed bug #29019 (Database not closing). (Marcus) +- Fixed bug #29008 (array_combine() does not handle non-numeric/string keys). + (Ilia) - Fixed bug #28895 (ReflectionClass::isAbstract always returns false). (Marcus) - Fixed bug #28868 (Internal filter registry not thread safe). (Sara) - Fixed bug #28851 (call_user_func_array has typo in error message). (Marcus) diff --git a/ext/standard/array.c b/ext/standard/array.c index d9c0216f8d..e7bc0a8e43 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -4246,6 +4246,17 @@ PHP_FUNCTION(array_combine) } else if (Z_TYPE_PP(entry_keys) == IS_LONG) { zval_add_ref(entry_values); add_index_zval(return_value, Z_LVAL_PP(entry_keys), *entry_values); + } else { + zval key; + + key = **entry_keys; + zval_copy_ctor(&key); + convert_to_string(&key); + + zval_add_ref(entry_values); + add_assoc_zval(return_value, Z_STRVAL(key), *entry_values); + + zval_dtor(&key); } zend_hash_move_forward_ex(Z_ARRVAL_P(keys), &pos_keys); zend_hash_move_forward_ex(Z_ARRVAL_P(values), &pos_values); -- 2.50.1