Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

2
  • 1
    The array_shift re index the key items if it's integer, so it's bad, so you can use this: stackoverflow.com/a/52826684/1407491 Commented Oct 16, 2018 at 1:31
  • The complexity of array_shift() is O(n) (due to re-indexing numeric indexes) and for array_pop() it is O(1). How to get to know the first element's index? Just start a foreach and break it right in its first iteration. Commented Oct 23, 2021 at 13:00