note 18313 deleted from function.array-reduce by levim

From: Date: Mon, 24 Feb 2014 16:20:31 +0000
Subject: note 18313 deleted from function.array-reduce by levim
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-198626@lists.php.net to get a copy of this message
Note Submitter: php dot net at cuntbubble dot com ---- 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 <?php 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 :)

« previous php.notes (#198626) next »