note 31776 deleted from control-structures.foreach by sniper
| From: | sniper@php.net | Date: | Wed, 08 Oct 2003 04:05:10 +0000 |
| Subject: | note 31776 deleted from control-structures.foreach by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58003@lists.php.net to get a copy of this message | ||
Note Submitter: guillemcatala404@hotmail.com
----
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;
}
}
}