RE: [PHP] question about foreach and associate array
| From: | Peter Lauri | Date: | Tue, 21 Feb 2006 04:58:49 +0000 |
| Subject: | RE: [PHP] question about foreach and associate array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230785@lists.php.net to get a copy of this message | ||
Just do:
$arg['textarea']['body']="Hello";
foreach($arg['textarea'] as $row) {
echo $row."<br/>";
echo $arg['textarea']['body']."<br/>";
}
The $row is an string, and what you are trying to do the $row['body']. And
php will translate 'body' to 0 in this, I do not know why :)
Try
echo $row['body']. $row[1]. $row[1]. $row[2]. $row[3]. $row[4];
It will probably echo Hello for you :)
/Peter
-----Original Message-----
From: jonathan [mailto:news_php@arclocal.com]
Sent: Tuesday, February 21, 2006 9:58 AM
To: php-general@lists.php.net
Subject: [PHP] question about foreach and associate array
I have the following construct:
$arg['textarea']['body']="Hello";
foreach($arg['textarea'] as $row)
{
echo $row['body']."<br/>";
echo $arg['textarea']['body']."<br/>";
}
I would expect both of them to output "Hello" but only the second
does. The first outputs "H". I thought I have done this before. Can
anybody tell me why this won't work?
thanks,
jonathan
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php