Reference to array element

Discussion in 'PHP' started by SeLfkiLL, Mar 30, 2007.

  1. #1
    Is it possible to have a reference to an array element? I've tried this with no luck:

    $array[0] = 'a';
    $ref &= $array[0];
    echo $ref; //output: 
    $ref = 'b';
    echo $ref; //output: b
    echo $array[0]; //output: a
    Code (markup):
    What am I missing here?
     
    SeLfkiLL, Mar 30, 2007 IP
  2. nico_swd

    nico_swd Prominent Member

    Messages:
    4,153
    Likes Received:
    344
    Best Answers:
    18
    Trophy Points:
    375
    #2
    The & should go behind the equal sign.
     
    nico_swd, Mar 30, 2007 IP
  3. SeLfkiLL

    SeLfkiLL Active Member

    Messages:
    85
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    50
    #3
    Oh you're right! Thanks, didn't spot that. You'd think they'd be consistent with all their other *= operators but oh well...
     
    SeLfkiLL, Mar 30, 2007 IP