What does [] mean when reading from a php array?

Venturer X

New Member
I've been writing a parser for PHP and while messing around with some third party code, I run into a weird case regarding the [] operator.Normally, [] is used without a key on the left side of an assignment meaning "add as the last element".\[code\]$a=array();$a[]=1;\[/code\]will add 1 in the end of array $a.In the aforementioned code though, I saw a line like this:\[code\]$r =& $a[];\[/code\]When I tried to remove the &, I got a rather expected Fatal Error:\[quote\] Fatal error: Cannot use [] for reading\[/quote\]With the & though, php does not complain at all. Do you know what is the meaning of the expression \[code\]& $a[];\[/code\]Thanks in advance
 
Back
Top