jonathan wrote:
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?
You have an associative array so you need to specify both parts:
foreach($arg['textarea'] as $area => $entry) {
echo $area . '<br/>'; // body
echo $entry . '<br/>'; // hello
}
Your method works ok for indexed arrays like:
$array[1] = "XYZ";
$array[2] = "ABC";
etc
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php