ID: 45700 Updated by: [EMAIL PROTECTED] Reported By: j dot jeising at gmail dot com -Status: Open +Status: Bogus Bug Type: Arrays related Operating System: * PHP Version: 5.2.6 New Comment:
Using PHP 5.3: Warning: array_reduce() expects parameter 3 to be long, array given in /usr/src/build/php_5_3CVS_tst/t.php on line 10 Current behaviour in 5.2 has existed long enough not to be broken in PHP 5.2 branch. Previous Comments: ------------------------------------------------------------------------ [2008-08-03 14:18:26] j dot jeising at gmail dot com Description: ------------ array_reduce only accepts integer as the $initial value. All other values are converted to long. This problem was already discussed in #42566, but the only answer is thats because of a fix to #29954. The fix for #29954 was the following change: if (ZEND_NUM_ARGS() > 2) { convert_to_long_ex(initial); result = *initial; } http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/array.c?r1=1.283&r2=1.284 That's not a proper fix to the problem. You can't solve a segfault with a type conversion - some functionality is missing here. Reproduce code: --------------- $array = array ( array ( 1 ), array ( 2 ) ); print_r ( array_reduce ( $array, 'array_merge', array ( ) ); Expected result: ---------------- Array ( [0] => 1, [1] => 2 ); Actual result: -------------- Warning: array_merge() [function.array-merge]: Argument #1 is not an array in test.php on line 3 => initial value is 1. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=45700&edit=1