Re: syntax for printing multi-dimensional arrays
| From: | Tom Rogers | Date: | Tue, 23 Mar 2004 10:18:55 +0000 |
| Subject: | Re: syntax for printing multi-dimensional arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181245@lists.php.net to get a copy of this message | ||
Hi,
Tuesday, March 23, 2004, 8:03:05 PM, you wrote:
BP> Hi all
BP> I am having problems printing members of an array that has two
BP> dimensions and am wondering if someone can help me with the syntax
BP> required to do this.
BP> If i have the follwing code:
BP> <?php
BP> $test=array('test1'=>'a','test2'=>'b');
BP> print "$test[test1]";
?>>
BP> I get 'a' echoed to the screen as expected. But if i make the array 2
BP> dimensional like this:
BP> <?php
BP> $test[0]=array('test1'=>'a','test2'=>'b');
BP> print "$test[0][test1]";
?>>
BP> I would expect to get 'a' echoed to the screen again but instead i get this:
BP> Array[test1].
BP> Has anyone seen this before and can help or point me to some goods docs
BP> on it?
BP> Thanks in advance for any help
BP> Cheers
BP> Bob
You don't need the outside quotes just
print $test[0]['test1']
( Note test1 needs the quotes )
If you need to output other stuff then use the . operator like
print 'Value = '.$test[0]['test1'].'<br>';
--
regards,
Tom