Array
(
[1] => 1
[2] => 1
[3] => 1
[4] => 1
[5] => 0
[6] => 1
[7] => 0
[8] => 0
)
Should do this: (completly delete previous elements)
found [5] => 0 then unset [4] => 1 and unset [5] => 0
found [7] => 0 then unset [6] => 1 and unset [7] => 0
found [8] => 0 then unset [3] => 1 (because 7,6,5,4 were already deleted)
and unset[8] => 0
Result:
Array
(
[1] => 1
[2] => 1
)
I've tried something like this, but it unsets only the current element, why?
foreach ($points as $key => $value) {
if ($value == '0') {
unset($points[$key]);
$prev = prev($points);
unset($prev);
}
}