note 8311 added to array
| From: | philip at thepr dot chek dot com | Date: | Tue, 05 Sep 2000 22:15:20 +0000 |
| Subject: | note 8311 added to array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-4178@lists.php.net to get a copy of this message | ||
//example
// Here's an array :
$canadian_provinces = array (
"AB" => "Alberta",
"BC" => "British Columbia",
"MB" => "Manitoba",
);
// We create a function called ulist(); to print ul list
function ulist($canadian_provinces) {
echo "<ul>\n";
while (list ($key, $val) = each($canadian_provinces)) {
echo "<li>$key = $val\n";
}
echo "</ul>\n\n";
}
// We use newly create function to print ul list
ulist($canadian_provinces);
// Which prints the following :
<ul>
<li>AB = Alberta
<li>BC = British Columbia
<li>MB = Manitoba
</ul>
http://www.php.net/manual/function.array.php