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
: [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
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
Hi Job. This works for me (and *should* always work) :
$a = array('foo' = 'bar');
$b = array('b' = 'foo');
print $a[$b['b']]; // prints bar
How _exactly_ are you calling it? (provide a short standalone ex)
Does the above example work for you?
What version of php?
regards,
Philip
[mailto:[EMAIL PROTECTED]]
Sent: giovedi 4 ottobre 2001 2.21
To: [EMAIL PROTECTED]
Subject: RE: [PHP] associative array syntax question
here is sample output from my script:
win98/Apache 1.3.19/php4.0.5
variable being displayed = value
$row[TICKER] = NTAP
$test = NTAP
$quotes[$test] = 8.30
$quotes
-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
: 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
: giovedi 4 ottobre 2001 2.44
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
)
[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
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
10 matches
Mail list logo