| 
 Posted by Ira Gladnick on 12/01/06 16:53 
Norman Peelman wrote: 
> You use { } on strings such as: 
> 
> $someString1 = "0123456789"; 
> $someString2 = "rock 'n roll"; 
> 
> echo $someString1{5} will output: 
> 5 
 
Interesting. 
 
But I was actually doing an assignment using the brace notation: 
    SomeArray{0} = $somevalue 
 
And, when I did a print_r($SomeArray), it displayed as being an array 
with the zero element being the assigned value (if I change the 
assignment to  SomeArray{99} = $somevalue, then it shows the 99th array 
element as holding $somevalue). 
 
So in this situation it seems that braces are equivalent to array 
brackets, and are doing something different than string indexing.  But 
as mentioned, I can't seem to find any documentation indicating this 
usage. 
 
This kind of brace usage came up in the context of a certification 
practice exam.
 
[Back to original message] 
 |