note 71059 added to function.each
| From: | Bleach984 at osu1 dot php dot net | Date: | Fri, 10 Nov 2006 01:43:07 +0000 |
| Subject: | note 71059 added to function.each | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-119575@lists.php.net to get a copy of this message | ||
have found something interesting.
when I use a FOREACH with the WHILE statement inside it as talk has been going on,
it will give you all of the values of a multi-dimensional array.
like this
<?php
$categories = return_cats();
foreach ( $categories as $category ) {
while(list($k, $v) = each ($category)) {
echo "$k ... $v <br />";
}
}
?>
will output something like this
Truecat_name ... Awesome
category_nicename ... awesome
cat_count ... 3
lastday ... 28
lastmonth ... 10
cat_name ... Uncategorized
category_nicename ... uncategorized
cat_count ... 1
lastday ... 28
lastmonth ... 10
cat_name ... Welcome Messages
category_nicename ... welcome-messages
cat_count ... 3
lastday ... 28
lastmonth ... 10
----
Server IP: 64.71.164.2
Probable Submitter: 67.171.176.126
----
Manual Page -- http://www.php.net/manual/en/function.each.php
Edit -- https://master.php.net/note/edit/71059
Del: integrated -- https://master.php.net/note/delete/71059/integrated
Del: useless -- https://master.php.net/note/delete/71059/useless
Del: bad code -- https://master.php.net/note/delete/71059/bad+code
Del: spam -- https://master.php.net/note/delete/71059/spam
Del: non-english -- https://master.php.net/note/delete/71059/non-english
Del: in docs -- https://master.php.net/note/delete/71059/in+docs
Del: other reasons-- https://master.php.net/note/delete/71059
Reject -- https://master.php.net/note/reject/71059
Search -- https://master.php.net/manage/user-notes.php