Re: multi-dimensional array won't echo
| From: | Rasmus Lerdorf | Date: | Sat, 25 Aug 2001 20:54:52 +0000 |
| Subject: | Re: multi-dimensional array won't echo | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-64455@lists.php.net to get a copy of this message | ||
> The first echo statement doesn't work, the second does. Anybody know
> why?
>
> $string1=15;
> $string2=27;
> $myarray[$string1][$string2]="syncopated";
> echo "$myarray[$string1][$string2]<br />\n"; //displays Array[27]
> echo $myarray[$string1][$string2] . "<br />\n"; //displays syncopated
Complex variables inside quoted strings need to be dereferenced using {}'s
eg.
echo "{$myarray[$string1][$string2]}<br />\n";
Or better yet:
echo $myarray[$string1][$string2] . "<br />\n";
-Rasmus