note 94518 added to function.array-reduce
| From: | JonP at osu1 dot php dot net | Date: | Tue, 10 Nov 2009 05:08:29 +0000 |
| Subject: | note 94518 added to function.array-reduce | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162685@lists.php.net to get a copy of this message | ||
This works as you want:
$html = "";
function reduceToTable($html, $p) {
global $html;
$html .= "<TR><TD><a
href=\"$p.html\">$p</a></td>\n";
return $html;
}
$list = Array("page1", "page2", "page3");
$tab = array_reduce($list, "reduceToTable");
echo "<table>\n". $tab . "</table>\n";
The output does not have any preceeding 0. This was being caused by the .= on a variable that
doesn't exist the first time through.
----
Server IP: 69.147.83.197
Probable Submitter: 71.75.235.214
----
Manual Page -- http://www.php.net/manual/en/function.array-reduce.php
Edit -- https://master.php.net/note/edit/94518
Del: integrated -- https://master.php.net/note/delete/94518/integrated
Del: useless -- https://master.php.net/note/delete/94518/useless
Del: bad code -- https://master.php.net/note/delete/94518/bad+code
Del: spam -- https://master.php.net/note/delete/94518/spam
Del: non-english -- https://master.php.net/note/delete/94518/non-english
Del: in docs -- https://master.php.net/note/delete/94518/in+docs
Del: other reasons-- https://master.php.net/note/delete/94518
Reject -- https://master.php.net/note/reject/94518
Search -- https://master.php.net/manage/user-notes.php