note 31776 added to control-structures.foreach
| From: | guillemcatala404 at hotmail dot com | Date: | Sat, 03 May 2003 08:42:01 +0000 |
| Subject: | note 31776 added to control-structures.foreach | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47414@lists.php.net to get a copy of this message | ||
If you fetch a multidimensional associative array from database note that you have to use [] when
defining the array, otherwise the code below won't work
while($this->fetchrow()){
$cats[] = array('id' => $this->record["id"],
'parentid' => $this->record["parentid"],
'cat' => $this->record['cat']
);
}
*atributes like record and functions like fetchrow() are from my own library
foreach($cats as $key => $value) {
if(is_numeric($key) && is_array($value)){
foreach($value as $key2 => $value2) {
echo $key."".$value2;
}
}
}
--
http://www.php.net/manual/en/control-structures.foreach.php
http://master.php.net/manage/user-notes.php?action=edit+31776
http://master.php.net/manage/user-notes.php?action=delete+31776
http://master.php.net/manage/user-notes.php?action=reject+31776