ID: 15378 Updated by: [EMAIL PROTECTED] Reported By: [EMAIL PROTECTED] Status: Bogus Bug Type: Arrays related Operating System: Linux 2.4, Apache 1.3.22 PHP Version: 4.1.1 New Comment:
[EMAIL PROTECTED] -- I was aware of that syntax but there are some cases (sql querys, cookies & headers) where it is not possible to write it that way and the only solution WAS to assign it to a simpler variable. [EMAIL PROTECTED] -- Thanks. I guess that solves this problem. And this is documented where? Previous Comments: ------------------------------------------------------------------------ [2002-02-05 06:29:42] [EMAIL PROTECTED] This is not true. The following is perfectly valid: echo "My first name is {$var['name']['first']}!"; ------------------------------------------------------------------------ [2002-02-05 03:21:08] [EMAIL PROTECTED] The correct syntax is: echo "My first name is ".$var[name][first]."!"; You cannot have comples variables inside quotes. ------------------------------------------------------------------------ [2002-02-05 00:34:07] [EMAIL PROTECTED] I should add that the the first level of the array works fine, it is just the second (& following) levels that cannot be used. <?php // This works: $var[name] = 'Caleb'; echo "I am $var[name]"; // This does not: $var[name][first] = 'caleb'; echo "I am $var[name][first]"; ------------------------------------------------------------------------ [2002-02-05 00:30:39] [EMAIL PROTECTED] <?php $var = array( 'name' => array( 'first' => 'Caleb', 'last' => 'Maclennan' ) ); echo "My first name is $var[name][first]!"; ?> Acutal Result: My first name is Array[first]! Correct Result: My first name is Caleb! This get's really nasty when useing 3 dimentional arrays to put data in SQL querys. The above example can easily be done by takeing the variable out of the quotes and useing "." to add it to the end, but there are other cases where the only solution is to do like this: <?php $tempVar = $var[name][first]; echo "My name is $tempVar"; ?> ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=15378&edit=1 -- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php