ID: 26747 Updated by: [EMAIL PROTECTED] Reported By: japril78 at hotmail dot com -Status: Open +Status: Bogus Bug Type: Variables related Operating System: WinXP Pro PHP Version: 4.3.4 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php Well, what did you expect? [1] is not part of the variables name, ${$arraypath}[1] works just fine. Secondly it is no wonder, that the function won't echo the value, because $array is not defined in that scope. Previous Comments: ------------------------------------------------------------------------ [2003-12-30 04:29:12] japril78 at hotmail dot com Description: ------------ This does not work as expected: $array = array('one','two','three'); $arraypath = 'array[1]'; echo ${$arraypath}; Workaround: $array = array('one','two','three'); $arraypath = 'array[1]'; eval('$value = $'.$arraypath.';'); echo $value; BUT: The workaround DOES NOT work inside a function. Reproduce code: --------------- $array = array('one','two','three'); $arraypath = 'array[1]'; $value = showit($arraypath); function showit($arraypath) { eval('$value = $'.$arraypath.';'); echo $value; // Attempt #1 echo $$arraypath; // Attempt #2 echo ${$arraypath}; // Attempt #3 } Expected result: ---------------- nothing Actual result: -------------- nothing ------------------------------------------------------------------------ [2003-12-30 04:27:43] japril78 at hotmail dot com Description: ------------ This does not work as expected: $array = array('one','two','three'); $arraypath = 'array[1]'; echo ${$arraypath}; Workaround: $array = array('one','two','three'); $arraypath = 'myarray[1]'; eval('$value = $'.$arraypath.';'); echo $value; BUT: The workaround DOES NOT work inside a function. Reproduce code: --------------- $array = array('one','two','three'); $arraypath = 'array[1]'; $value = showit($arraypath); function showit($arraypath) { eval('$value = $'.$arraypath.';'); echo $value; // Attempt #1 echo $$arraypath; // Attempt #2 echo ${$arraypath}; // Attempt #3 } Expected result: ---------------- nothing Actual result: -------------- nothing ------------------------------------------------------------------------ [2003-12-30 04:26:54] japril78 at hotmail dot com Description: ------------ The does not work as expected: $array = array('one','two','three'); $arraypath = 'array[1]'; echo ${$arraypath}; Workaround: $array = array('one','two','three'); $arraypath = 'myarray[1]'; eval('$value = $'.$arraypath.';'); echo $value; BUT: The workaround DOES NOT work inside a function. Reproduce code: --------------- $array = array('one','two','three'); $arraypath = 'array[1]'; $value = showit($arraypath); function showit($arraypath) { eval('$value = $'.$arraypath.';'); echo $value; // Attempt #1 echo $$arraypath; // Attempt #2 echo ${$arraypath}; // Attempt #3 } Expected result: ---------------- nothing Actual result: -------------- nothing ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=26747&edit=1