Jump to content

Using A Variable In An Array


jeff5656

Recommended Posts

Let's say I have a bunch of records in an array and I want to echo one out:

 

echo $somarray['somefield'];

 

but lets say I want to have a variable instead of "somefield".

 

How do I do this? This is what I want to do but the syntax is wrong:

$hello = "somefield"
echo $somarray['$hello'];

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/270859-using-a-variable-in-an-array/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.