The array_product() function is completely broken. I've filed a bug at 
http://bugs.php.net/bug.php?id=35014 describing the problem, but to summarise 
it returns 0 for all valid input and when the input is an empty array.

I've also posted a patch, which fixes everything for me. I would appreciate 
any feedback, especially since this is my first patch :)

Thanks,
Arpad Ray

Index: ext/standard/array.c
===================================================================
RCS file: /repository/php-src/ext/standard/array.c,v
retrieving revision 1.308.2.10
diff -u -u -b -B -r1.308.2.10 array.c
--- ext/standard/array.c        28 Oct 2005 09:57:35 -0000      1.308.2.10
+++ ext/standard/array.c        29 Oct 2005 06:04:22 -0000
@@ -3997,7 +3997,12 @@
                return;
        }

-       ZVAL_LONG(return_value, 0);
+       if (zend_hash_num_elements(Z_ARRVAL_PP(input)) == 0) {
+               php_error_docref(NULL TSRMLS_CC, E_WARNING, "Array must 
contain at least one element");
+               return;
+       }
+
+       ZVAL_LONG(return_value, 1);

        for (zend_hash_internal_pointer_reset_ex(Z_ARRVAL_PP(input), &pos);
                 zend_hash_get_current_data_ex(Z_ARRVAL_PP(input), (void 
**)&entry, &pos) == SUCCESS;

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to