note 71059 rejected from function.each by nicobn
[email protected] Fri, 18 Feb 2011 08:07:20 -0800
| Newsgroups | php.notes |
|---|---|
| Message-ID | <[email protected]> |
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