|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #26980 Array creation with '{}' instead of '[]'
Submitted: 2004-01-20 12:43 UTC Modified: 2004-01-20 14:26 UTC
From: reklov at unitedklasens dot de Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 4.3.4 OS: Win98SE
Private report: No CVE-ID: None
 [2004-01-20 12:43 UTC] reklov at unitedklasens dot de
With $var{$i} = 'Test' I wanted to create a variable with the name 'var1', using the '{}' and $i == 1, like ${$a} (
Insted of this, it will create an array, as if I had used '[]' instead of '{}'.

Reproduce code:
$i = 1;
$var{$i} = 'Test';
echo $var{$i};
echo '<br>';
echo $var{1};
echo '<br>';
echo $var1;

Expected result:
Test<br>  //not sure, what would happen...

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-20 14:26 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

{} 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.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Thu Oct 06 14:03:44 2022 UTC