in reply to Re: can't remove all zeroes from an array
in thread can't remove all zeroes from an array
When you splice like this, items with a larger index shift forward, but those with a lower index remain in place — so the problem simply vanishes by looping back to front.
$i = @arry; while ( --$i >= 0 ) { if ($arry[$i] == 0) {splice @arry, $i,1;} }
|
|---|