#26980 [Opn->Bgs]: Array creation with '{}' instead of '[]'
| From: | helly@php.net | Date: | Tue, 20 Jan 2004 19:26:44 +0000 |
| Subject: | #26980 [Opn->Bgs]: Array creation with '{}' instead of '[]' | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-53650@lists.php.net to get a copy of this message | ||
ID: 26980
Updated by: helly@php.net
Reported By: reklov at unitedklasens dot de
-Status: Open
+Status: Bogus
Bug Type: Arrays related
Operating System: Win98SE
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
{} can be used to denoted array or string indices.
You would need this: ${var${i}}
Nothe that the second '{' here is after the second '$' not before as in
your code. The notation should force the compiler to generate code that
concatenates the string var with the result of variable $i and use that
as a variable name.
This is neither possible nor planned. You need to evaluate the value of
the mentioned concatentaion yourself.
Previous Comments:
------------------------------------------------------------------------
[2004-01-20 12:43:42] reklov at unitedklasens dot de
Description:
------------
With $var{$i} = 'Test' I wanted to create a variable with the name
'var1', using the '{}' and $i == 1, like ${$a}
(http://www.php.net/manual/en/language.variables.variable.php)
Insted of this, it will create an array, as if I had used '[]' instead
of '{}'.
Reproduce code:
---------------
<?php
$i = 1;
$var{$i} = 'Test';
echo $var{$i};
echo '<br>';
echo $var{1};
echo '<br>';
echo $var1;
?>
Expected result:
----------------
Test<br>
Test<br> //not sure, what would happen...
Test
Actual result:
--------------
Test<br>
Test<br>
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=26980&edit=1