Page 1 of 1

reset array keys, starting at 0

Posted: Fri May 18, 2007 11:21 pm
by GeXus
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?

Posted: Fri May 18, 2007 11:28 pm
by volka

Posted: Fri May 18, 2007 11:46 pm
by GeXus
perfect.. thanks!

Re: reset array keys, starting at 0

Posted: Sat May 19, 2007 4:30 am
by stereofrog
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?
Do not unset() the first elem, do array_shift() instead.

Posted: Sat May 19, 2007 9:24 am
by GeXus
Ah, excellent.. double whammy.. thanks!