Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Is it possible to reference an associative array key by it's position

Looking for a way to reference variable associative array key names.

6:39 pm on Mar 7, 2010 (gmt 0)

Preferred Member

10+ Year Member

joined:Sept 28, 2004
posts: 351
votes: 0

Hi Everyone,

Is it possible to refer to an associative array key by the position it was added to the array?

For example, let's say that I have a dynamic result set. I don't know the column names (e.g. associative array key names), but would like to reference the first column or second column numerically.

Is there a built-in function to do this (couldn't find one), or do I need to loop through the keys and assign them to a numerically indexed array.

Let me know if that question makes sense. I always struggle with arrays.

6:06 am on Mar 8, 2010 (gmt 0)

Senior Member

WebmasterWorld Senior Member 10+ Year Member

joined:Apr 24, 2005
votes: 0


any index can still be accessed numerically, like this

echo $myArray[1]; //"World"
echo $myArray[2]; //"Testing"

Same for multidimensional arrays
Sorry if i have not understood the question correctly.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members