note 18313 added to function.array-reduce

From: Date: Fri, 18 Jan 2002 01:08:43 +0000
Subject: note 18313 added to function.array-reduce
Groups: php.notes 
Request: Send a blank email to php-notes+get-25010@lists.php.net to get a copy of this message
There is an error/misleading item in the documentation [, int initial] int is not constrained to an integer, it can be any data type (although I've not tested ALL data types) and $v is the cumulative part, the current value of the reduction. and I'll take the liberty to add another example, as used in my code function reduceToTable($html, $p) { $html .= "<TR><TD><a href=\"$p.html\">$p</a></td>\n"; return $html; } $list = Array("page1", "page2", "page3"); $tab = array_reduce($list, "reduceToTable", "<table>\n"); echo $tab . "</table>\n"; hmm, getting stuff on one line sure is tricky, it get's wordwrapped on the char count in html so &gt; counts as 4 chars not one so by the time you've counted "< you've used up 8 chars If it get's through moderation could someone please make it look ok :) -- http://www.php.net/manual/en/function.array-reduce.php http://master.php.net/manage/user-notes.php?action=edit+18313 http://master.php.net/manage/user-notes.php?action=delete+18313 http://master.php.net/manage/user-notes.php?action=reject+18313

« previous php.notes (#25010) next »