0

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?

0

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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?
Keep an eye on the documentation, they're pretty good about letting you know which ones do, they also call it an array cursor.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.