Maybe this is obvious, but end() returns the last array element and moves the pointer. It's that "moves the pointer" langauge that makes me nervous though. When using array_push or $thearray[] = "" or any other method of appending to the array, will the use of end() mean that the next added element will overwrite the last existing element?
Add a comment
|
1 Answer
Only the array functions like next, end, reset, each, etc all use the array internal pointer.
array_push() will always push elements to the end of the array and things like array_shift() will always shift elements off the start.
To learn more about the internal pointer, check out this other answer
2 Comments
not_a_generic_user
Thanks! I guess that's covered then for what I'm doing, but in general, how can I tell which functions will use the array pointer and which won't?
castis
Keep an eye on the documentation, they're pretty good about letting you know which ones do, they also call it an array cursor.