reset array keys, starting at 0
Moderator: General Moderators
reset array keys, starting at 0
I have an array, and based on a condition it will unset the first element... The array always starts out with keys 0,1,2,3, etc.. So when I unset the first one i'm left with 1,2,3, etc.. How do I resest the keys? so that they start at 0 again? Is there a function to simply do this?
- stereofrog
- Forum Contributor
- Posts: 386
- Joined: Mon Dec 04, 2006 6:10 am
Re: reset array keys, starting at 0
Do not unset() the first elem, do array_shift() instead.GeXus wrote:I have an array, and based on a condition it will unset the first element... The array always starts out with keys 0,1,2,3, etc.. So when I unset the first one i'm left with 1,2,3, etc.. How do I resest the keys? so that they start at 0 again? Is there a function to simply do this?