note 18313 modified in function.array-reduce by vrana
| From: | vrana@php.net | Date: | Tue, 17 Aug 2004 14:48:53 +0000 |
| Subject: | note 18313 modified in function.array-reduce by vrana | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-80069@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
<?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 > 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 :)
--was--
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 > 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://php.net/manual/en/function.array-reduce.php