Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reference to an array element

Status
Not open for further replies.

crackn101

Programmer
Dec 27, 2002
63
0
0
US
Hi Guys,
I had a quick question about referencing array elements.

I wanted to create a "shortcut" to a specific array element as a reference so as to Not create a copy of the data.

I just wanted to make sure that I understood this correctly.

Thanks.

Sample code:
Code:
$aData['texas']['dealer']['color']['red']="yes";
$aData['texas']['dealer']['color']['blue']="no";
$aData['texas']['dealer']['color']['green']="maybe";

$ref_colors = & $aData['texas']['dealer']['color'];

print $ref_colors['red'];
output: yes
 
looks ok. it is more usual to place the ampersand directly adjacent to the assignment operator. but this is just stylistic.
 
Thanks for the feedback. Prior to posting, I had googled numerous articles on referencing in php. Some where helpful and some were downright confusing.
Just making sure.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top