#42691 [NEW]: array_reduce: initial parameter should allow non-numeric values

From: Date: Tue, 18 Sep 2007 02:27:59 +0000
Subject: #42691 [NEW]: array_reduce: initial parameter should allow non-numeric values
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-117614@lists.php.net to get a copy of this message
From: tjerk dot meesters at muvee dot com Operating system: Linux 2.6 PHP version: 5.2.4 PHP Bug Type: Arrays related Bug description: array_reduce: initial parameter should allow non-numeric values Description: ------------ array_reduce() accepts an initial value to be passed as the first argument in the callback function instead of NULL. However, this initial value - if passed - is converted to an int. This is probably because the more common use of this idiom is for mathematical reduction. It would be helpful to allow other types to be passed such as strings or objects. Note: this ticket is a duplicate for #42566, but the reporter never bothered to follow up. Reproduce code: --------------- <?php echo array_reduce( array(' ','world'), create_function( '$total,$new', 'return $total.$new;' ), 'hello' ); ?> Expected result: ---------------- hello world Actual result: -------------- 0 world -- Edit bug report at http://bugs.php.net/?id=42691&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42691&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42691&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42691&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42691&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42691&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42691&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42691&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42691&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42691&r=support Expected behavior: http://bugs.php.net/fix.php?id=42691&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42691&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42691&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42691&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42691&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42691&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42691&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42691&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42691&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42691&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42691&r=mysqlcfg

« previous php.bugs (#117614) next »