Hi,
Is there a way of removing "holes" from an array. These "holes" are created when I unset an array element.
e.g.
$stack = array ("orange", "apple", "raspberry");
if I remove (unset($stack[1]), i am left with a hole in $stack.
$stack has now element indexes 0 and 2.
Note: if i sort this array, i get the indexes re-generated, and the "holes" removed, but it works only for more than 2 elements.
$stack = array ("orange", "apple") ;
if I unset($stack[0]) and sort $stack, i don't get the element "apple" at position 0.
The reason i need "holes" to be removed is for the For loop, where the counter increments every time and when the counter reaches the element "hole", i want to skip the "hole".
Any solutions on removing "holes" from array and regenerate the indexes properly, even in a 2 element array ?
Thank you.
Brij.