|
Posted by Colin Fine on 12/08/05 12:01
julian_m wrote:
> Chung Leong wrote:
>
>>// second
>>$line = array();
>>$lines[] =& $line;
>
>
> Can anyone tell me what is the 2nd line? I mean, the first one declares
> an array named "line", but the 2nd one?
> I'm comfused by & and [] there, and as you can imagine, i'm a kind of
> beginner right now...
>
> regards - julian
>
The second line adds a *reference* to the variable $line to the end of
array $lines; or to put it another way, it makes $lines[0] another name
for the same thing as $line. This means that even if the code later said
$line = 22;
(perfectly valid, though odd - it simply forgets about the array)
$lines[0] will have value 22.
If the '&' weren't there, then after
$line = 22,
$lines[0] will still be an array.
Colin
[Back to original message]
|