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)

10+ Year Member

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)

WebmasterWorld Senior Member 10+ Year Member


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.

Featured Threads

Hot Threads This Week

Hot Threads This Month