Page 1 of 1

[SOLVED] Unset array and then shift next one to fill in...?

Posted: Thu Aug 19, 2004 6:05 am
by tomfra
When I unset array it indeed removes the element I wanted to get rid of but instead of shifting the array it simply skips it so it looks like:

Array
(
[1] => string2
[3] => string3
)

In other words, [0] & [2] have been skipped in this example. How can I make it so that the resulting array looks like:

Array
(
[0] => string2
[1] => string3
)

Thanks!

Tomas

Posted: Thu Aug 19, 2004 6:56 am
by CoderGoblin
I do not know if there is an easier way but you could use $array=array_values($array);

Posted: Thu Aug 19, 2004 7:10 am
by tomfra
It seems to be working :)

Thanks a lot! I knew it would be something as simple as this but just couldn't find it.

Tomas