#24335 [Opn->WFx]: Use of $$var and arrays
| From: | derick@php.net | Date: | Thu, 26 Jun 2003 12:08:55 +0000 |
| Subject: | #24335 [Opn->WFx]: Use of $$var and arrays | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-42538@lists.php.net to get a copy of this message | ||
ID: 24335
Updated by: derick@php.net
Reported By: steve at oneniltrade dot com
-Status: Open
+Status: Wont fix
Bug Type: Feature/Change Request
Operating System: Linux
PHP Version: 4.3.2
New Comment:
Nope, this will most likely never be implemented.
Previous Comments:
------------------------------------------------------------------------
[2003-06-26 06:39:12] steve at oneniltrade dot com
Hi
This may not be a 'bug' as such, but it was submitted as much as a
feature request as a bug report, it would be really useful if it did
work as i've described (or at least I think so.) Any chance of this
feature being added to a future version?
------------------------------------------------------------------------
[2003-06-26 05:24:38] mgf@php.net
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
You can only use variable variables for the name of the array itself --
you can't specify any subscripts using this mechanism.
I suggest you post the underlying problem you are trying to solve to
php-general to see if anyone has any alternative suggestions.
------------------------------------------------------------------------
[2003-06-25 08:58:25] steve at oneniltrade dot com
Description:
------------
I'm trying to use variable variables to build up an array in a
recursive function, but this doesn't seem to be possible.
the following short amount of code illustrates the problem.
$str="array";
${$str}[1]="one";
print_r ($$str);
echo "<br>";
print_r ($array);
.............Output..........
Array ([1]=>one)
Array ([1]=>one)
As expected,
However
$str="array[1]";
$$str="One";
print_r ($$str);
echo "<br>";
print_r ($array);
............Output..........
One
No output, ie $array has no value.
Although $str has the value array[1], $$str is not the same as
$array[1], as I believe it should be. (Or needs to be to get my
function to work)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=24335&edit=1