Bug #15378 Updated: 3d array variables not usable in double quotes

From: Date: Tue, 05 Feb 2002 05:34:07 +0000
Subject: Bug #15378 Updated: 3d array variables not usable in double quotes
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-79177@lists.php.net to get a copy of this message
ID: 15378 Updated by: php.net@chiefworks.com Reported By: php.net@chiefworks.com Status: Open Bug Type: Arrays related Operating System: Linux 2.4, Apache 1.3.22 PHP Version: 4.1.1 New Comment: 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]"; Previous Comments: ------------------------------------------------------------------------ [2002-02-05 00:30:39] php.net@chiefworks.com <?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

« previous php.dev (#79177) next »