]> granicus.if.org Git - php/commitdiff
@- Fixed a bug in preg_replace() that would change the type of the replacement
authorAndrei Zmievski <andrei@php.net>
Wed, 17 Oct 2001 18:20:19 +0000 (18:20 +0000)
committerAndrei Zmievski <andrei@php.net>
Wed, 17 Oct 2001 18:20:19 +0000 (18:20 +0000)
@  array entries to string. (Andrei)

ext/pcre/php_pcre.c

index 381c1b4eede88ce120515dc3c7b4ecaf5663c3be..74caa0f0e9828438c85ec20c9366092d99e4a40d 100644 (file)
@@ -704,7 +704,6 @@ char *php_pcre_replace(char *regex,   int regex_len,
                        return NULL;
                }
        } else {
-               convert_to_string(replace_val);
                replace = Z_STRVAL_P(replace_val);
                replace_len = Z_STRLEN_P(replace_val);
                replace_end = replace + replace_len;
@@ -906,6 +905,9 @@ static char *php_replace_in_subject(zval *regex, zval *replace, zval **subject,
                        if (Z_TYPE_P(replace) == IS_ARRAY && !is_callable_replace) {
                                /* Get current entry */
                                if (zend_hash_get_current_data(Z_ARRVAL_P(replace), (void **)&replace_entry) == SUCCESS) {
+                                       if (!is_callable_replace) {
+                                               convert_to_string_ex(replace_entry);
+                                       }
                                        replace_value = *replace_entry;
                                        zend_hash_move_forward(Z_ARRVAL_P(replace));
                                } else {