|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-09-05 14:59 UTC] lindsay at marshall dot name
Description: ------------ If you want to use array_reduce to produce a string rather than a number you cannot set the initial string to be '' as it is converted to 0. You can work round this but it is not elegant. There seems to be no reason why array_reduce should not work with strings (it did in 4.x) Reproduce code: --------------- see comment on array_reduce page Expected result: ---------------- see comment on array_reduce page PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 19:00:02 2025 UTC |
A short but complete example (copied from the cited user notes on the array_reduce page): <?php function arc ($reduced, $item) { $reduced = $item.$reduced; return $reduced; } array_reduce( array(a,b,c), "arc", "" ); ?> Expected result: cba Actual result: cba0