note 71059 rejected from function.each by nicobn
| From: | nicobn@php.net | Date: | Fri, 18 Feb 2011 16:07:20 +0000 |
| Subject: | note 71059 rejected from function.each by nicobn | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-177119@lists.php.net to get a copy of this message | ||
Note Submitter: Bleach984
----
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