note 52796 added to control-structures.foreach
| From: | MichaelT dot McGrew at osu1 dot php dot net | Date: | Thu, 12 May 2005 17:11:22 +0000 |
| Subject: | note 52796 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-89344@lists.php.net to get a copy of this message | ||
This can be used to creat a list of urls for a nav bar or links section etc. If you draw the values
of array from a mysql database it can be very usefull.
<?php
$arr = array(news, events);
foreach ($arr as $value) {
echo "<tr><td>Manage <a
href=\"./".$value.".php\">".$value."</a></td></tr>";
}
?>
will return
<tr>
<td>Manage <a href="./news.php">news</a>
</td>
</tr>
<tr><td>Manage <a href="./events.php">events</a>
</td>
</tr>
----
Manual Page -- http://www.php.net/manual/en/control-structures.foreach.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+52796
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52796&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52796&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52796&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52796&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52796&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+52796&report=yes
Search -- http://master.php.net/manage/user-notes.php