If any part of LIST is an array, "foreach" will get very confused if you add or remove elements within the loop body, for example with "splice". So don't do that.
In this situation I usually (as others have suggested) use a C-style for loop.
In reply to Re^2: Removing array elements
by mrpeabody
in thread Removing array elements
by sandrider
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |