Re: question about foreach and associate array
| From: | Jochem Maas | Date: | Tue, 21 Feb 2006 09:48:41 +0000 |
| Subject: | Re: question about foreach and associate array | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-230794@lists.php.net to get a copy of this message | ||
jonathan wrote:
I have the following construct:$row contains the _string_ 'Hello'. the thing is you can use array-like notation to get at the individual chars of a string....e.g: echo $row[0]; // outputs an 'H' when you try to grab the char at index position 'body' in the string 'Hello' the string 'body' is first converted to an integer to determine what the char offset is. i.e. echo (int)"body";$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