#41687 [Opn]: Array named from other variable doesn't return value for given index

From: Date: Thu, 14 Jun 2007 11:29:05 +0000
Subject: #41687 [Opn]: Array named from other variable doesn't return value for given index
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-113779@lists.php.net to get a copy of this message
ID: 41687 User updated by: dr dot diesel at seznam dot cz Reported By: dr dot diesel at seznam dot cz Status: Open Bug Type: Arrays related Operating System: Win XP PHP Version: 5.2.3 New Comment: Sorry, $$arrname = array(204,205); should be the second line. Previous Comments: ------------------------------------------------------------------------ [2007-06-14 11:26:31] dr dot diesel at seznam dot cz Description: ------------ Code snippet says everything: $arrname="my_array"; $$arrname = array("test","test2"); var_export($$arrname) outputs: array ( 0 => '204', 1 => '205', ) var_export($$arrname[0]) outputs: NULL $test=$$arrname; var_export($test) outputs: array ( 0 => '204', 1 => '205', ) var_export($test[0]) outputs:'204' Reproduce code: --------------- $arrname="my_array"; $$arrname = array("test","test2"); var_export($$arrname); var_export($$arrname[0]); $test=$$arrname; var_export($test); var_export($test[0]); Expected result: ---------------- $arrname="my_array"; $$arrname = array("test","test2"); var_export($$arrname) outputs: array ( 0 => '204', 1 => '205', ) var_export($$arrname[0]) outputs: >>>>>>>>'204'<<<<<<<<< $test=$$arrname; var_export($test) outputs: array ( 0 => '204', 1 => '205', ) var_export($test[0]) outputs:'204' Actual result: -------------- $arrname="my_array"; $$arrname = array("test","test2"); var_export($$arrname) outputs: array ( 0 => '204', 1 => '205', ) var_export($$arrname[0]) outputs: NULL $test=$$arrname; var_export($test) outputs: array ( 0 => '204', 1 => '205', ) var_export($test[0]) outputs:'204' ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41687&edit=1

« previous php.bugs (#113779) next »