From: Keith D. <ya...@ke...> - 2002-09-07 20:02:43
|
>I have a question about PHP. It says that it is an "ordered map" but all of the examples I've seen show an associative container. In other words, is array( 'a' => 'b', 'c' => 'd') distinguishable from array( 'c' => 'd', 'a' => 'b'). If not, it is an associative container and not a "ordered map" as it says. If it is an ordered map, what is the syntax to get the nth key? When you do a foreach(){}, or use each(), you get the elements back in the same order you put them in. You can do current(), next(), prev(), end(), and reset() operations on a PHP array. Finally, you also get stack and queue operations like array_push(), array_pop(), array_shift(), and array_unshift(). I suppose you can't get the nth element from an array that isn't indexed by number without going through and counting :) but usually you don't need to do that. Also, if you test to see if the two arrays above are equal (==) they are, but if you test to see if they're "really equal" (===) they're not. So you have a little bit of both worlds. Keith |