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!

Using a variable as the key to an array

Status
Not open for further replies.

bentleykf

Programmer
Apr 29, 2002
59
0
0
AU
i want to do the following but php is giving me a hard time doing this

echo $pictures[$namearray[1]][1];

the variable $namearray[1] equals fosters1, which is the key. If i replace this with the following

echo $pictures[fosters1][1];

it works fine, so whats up????
 
$pictures[fosters1][1] works because PHP is interpreting it as
$pictures['fosters1'][1]

I've not had problems using an array element's value as the index of another array. What do you mean by "giving [you] a hard time"?

Want the best answers? Ask the best questions: TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top