|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2007-03-04 17:21 UTC] iliaa@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
Description: ------------ array_reduce seems to modify, after one call, arrays which have only one item. This can be observed with many different ways. One example code is given. Reproduce code: --------------- <?php function CommaSeperatedList($a, $b) { if($a == null) return $b; else return $a.','.$b; } $arr1 = array(1,2,3); $arr2 = array(1); echo "result for arr1: ".array_reduce($arr1,'CommaSeperatedList')."<br>"; echo "result for arr2: ".array_reduce($arr2,'CommaSeperatedList')."<br>"; echo "result for arr1: ".array_reduce($arr1,'CommaSeperatedList')."<br>"; echo "result for arr2: ".array_reduce($arr2,'CommaSeperatedList')."<br>"; ?> Expected result: ---------------- result for arr1: 1,2,3 result for arr2: 1 result for arr1: 1,2,3 result for arr2: 1 Actual result: -------------- result for arr1: 1,2,3 result for arr2: 1 result for arr1: 1,2,3 result for arr2: