Php keeps track of a couple of several things related to an array; including how many elements are in it, and which element in the array is "current".
You can index an array by position :
x[1] = 42;
Or you can use a string as the index:
x["Fred"] = 42;
Or you can tell php to just use the next available element:
x[] = 42;
You can get the index and value of whatever array element is "current" with key(x) and current(x). The key() function is usually used with a "foreach" loop when you want to step through every array element, but you used strings (as in the second example above) so a normal "for" loop (on numbers) won't work.