|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2008-08-04 21:26 UTC] jani@php.net
[2008-08-04 22:00 UTC] j dot jeising at gmail dot com
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Oct 28 16:00:01 2025 UTC |
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.