dewcansam wrote:Maybe i guess i am, because i know that fetch the result and can refer to index 0 as both 0 and "id" (just an example) and i could have sworn that i have done it to standard assoc arrays as well.
Well.. I can "swear" that you haven't. :p The only reason that the integer as well as the string index works when using the 'fetch_row' DB command is because those functions explicitly duplicate the data in the array under both key names.
No.. that post indicates that some user thought you could access it that way. Did you actually try the code? I tried this:
$team1 = array("wins" => 5, "ties" => 3, "loses" => 2);
echo $team1[1]; // 3
echo $team1[0]; // 5
echo $team1["loses"]; // 2
echo $team1["wins"]; // 5
and was greeted with the following (expected) error messages:
Notice: Undefined offset: 1 in D:\php\test.php on line 4
Notice: Undefined offset: 0 in D:\php\test.php on line 5
dewcansam wrote:So anyways, is there anyway that you can reference an assoc array by index ?
There is, in a roundabout way, but why would you want to? If the data in the array was mapped using a key such as "id", then why would you want to arbitrarily pick something out of the nth position in the array?
The only real way I can think of to access an associative array by index number would be to use [man]array_keys/man to get the values of the keys in the array in a numerically indexed array, and then use that array to get the nth array key and address the original array that way, e.g.
echo $array[$keys[1]];
But again, I don't understand how this could be practically useful.