Yes, that does for sure

Maxim Maletsky
www.PHPBeginner.com



-----Original Message-----
From: Matthew Loff [mailto:[EMAIL PROTECTED]] 
Sent: giovedi 4 ottobre 2001 4.02
To: 'Job Miller'; 'Maxim Maletsky (PHPBeginner.com)';
[EMAIL PROTECTED]
Subject: RE: [PHP] associative array syntax question - got it!



Have you tried using curly brackets?

print "<td>$a[B]<td>{$quotes[$a[B]]}<td>"

Does that work?  Just cuious...


-----Original Message-----
From: Job Miller [mailto:[EMAIL PROTECTED]] 
Sent: Wednesday, October 03, 2001 8:44 PM
To: Maxim Maletsky (PHPBeginner.com); [EMAIL PROTECTED]
Subject: Re: [PHP] associative array syntax question - got it!


Maxim,

I figured it out.  Thanks for your help

PHP can't interpolate within string when nested
associative array is used.  the nested aa must be
appended with dot notation, and if you try to print it
within the outer quotes it balks!

print "<td>$a[B]<td>".$quotes[$a[B]]."<td>"
           ^^^^^      ^^^^^^^^^^^^^^     
             A              B

This works, B switched with A won't work though.      
 

Thanks again,

Job
--- "Maxim Maletsky (PHPBeginner.com)" <[EMAIL PROTECTED]>
wrote:
> 
> 
> -----Original Message-----
> From: Maxim Maletsky (PHPBeginner.com)
> [mailto:[EMAIL PROTECTED]]
> Sent: giovedi 4 ottobre 2001 2.02
> To: 'Job Miller'
> Subject: RE: [PHP] associative array syntax question
> 
> 
> 
> I tried on winXP/PHP4.0.6/Apache
> 
> <?
>       $a = Array('print me');
>       $b = Array('b'=>0);
>       print $a[$b['b']]
> 
>       # prints:
>       # print me
> ?>
> 
> 
> Strange, should work though....
> 
> Maxim Maletsky
> www.PHPBeginner.com
> 
> 
> 
> -----Original Message-----
> From: Job Miller [mailto:[EMAIL PROTECTED]]
> Sent: giovedi 4 ottobre 2001 1.57
> To: Maxim Maletsky (PHPBeginner.com)
> Subject: RE: [PHP] associative array syntax question
> 
> 
> no luck with that either.
> I do the same thing in Perl all the time.
> can it have anything to do with the fact that the
> inner part is a fetch from a mySQL DB which returns
> an enumerated array,
> so b is actually a constant (drop the quotes)
> referring to an index in
> the result?
> 
> i tried $a[$b[b]] and $a[{$b[b]}], etc..
> 
> nothing works..
> 
> 
> --- "Maxim Maletsky (PHPBeginner.com)" <[EMAIL PROTECTED]>
> wrote:
> > Strange, I always though it should be working.
> > 
> > Have you tried $a[{$b['b']}] ?
> > 
> > What version of PHP are you running?
> > 
> > Maxim Maletsky
> > www.PHPBeginner.com
> > 
> > 
> > 
> > -----Original Message-----
> > From: Job Miller [mailto:[EMAIL PROTECTED]]
> > Sent: giovedi 4 ottobre 2001 1.41
> > To: [EMAIL PROTECTED]
> > Subject: [PHP] associative array syntax question
> > 
> > 
> > why does: print $a[$b['b']] return:
> > 
> > parse error, expecting `T_STRING' or `T_VARIABLE'
> or `T_NUM_STRING'
> > 
> > but if I do it in two steps like:
> > 
> > $c=$b['b'];
> > print $a[$c];
> > 
> > it works fine.
> > 
> > I have tried dozens of syntax combinations using
> > quotes, no quotes, on one or both and can't get
> > anything to work.  any help would be greatly
> > appreciated.  The two step method is annoying.
> > 
> > Job
> >  
> > 
> > __________________________________________________
> > Do You Yahoo!?
> > NEW from Yahoo! GeoCities - quick and easy web
> site
> > hosting, just
> > $8.95/month. http://geocities.yahoo.com/ps/info1
> > 
> > --
> > 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]
> > 
> > 
> > 
> > --
> > 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]
> > 
> 
> 
> __________________________________________________
> Do You Yahoo!?
> NEW from Yahoo! GeoCities - quick and easy web site
> hosting, just
> $8.95/month. http://geocities.yahoo.com/ps/info1
> 
> 
> --
> 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]
> 


__________________________________________________
Do You Yahoo!?
NEW from Yahoo! GeoCities - quick and easy web site hosting, just
$8.95/month. http://geocities.yahoo.com/ps/info1

-- 
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]



-- 
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]

Reply via email to