Re: [PHP] multi-dimensional array won't echo

2001-08-25 Thread bill

Not only a good answer, but the best explanation.

thanks,

bill hollett

Rasmus Lerdorf wrote:

> > 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]\n";   //displays Array[27]
> > echo $myarray[$string1][$string2] . "\n";  //displays syncopated
>
> Complex variables inside quoted strings need to be dereferenced using {}'s
>
> eg.
>
> echo "{$myarray[$string1][$string2]}\n";
>
> Or better yet:
>
> echo $myarray[$string1][$string2] . "\n";
>
> -Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] multi-dimensional array won't echo

2001-08-25 Thread Rasmus Lerdorf

> 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]\n";   //displays Array[27]
> echo $myarray[$string1][$string2] . "\n";  //displays syncopated

Complex variables inside quoted strings need to be dereferenced using {}'s

eg.

echo "{$myarray[$string1][$string2]}\n";

Or better yet:

echo $myarray[$string1][$string2] . "\n";

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]