In some tests I did with PHP, I saw that it is possible to use keys ( {}
) to access indexes of arrays
.
Example:
$array = ['a' => 1, 'b' => 2, 'c' => ['d' => 4]]
echo $array{'c'}{'d'}; // 4
echo $array{'c'}['d']; // 4
Until then, I thought that only the brackets ( []
) did that.
So, I want to ask:
-
Accessing an index of a
array
with braces instead of brackets has any special significance? -
Why is it possible to use both forms?
-
Using keys would be considered non-standard? I ask this because, although it works, I've never seen anyone using it.