Snippets tagged “foreach-loop”
2 snippets use this tag.
- Calling remove in foreach loop in JavaJava
If you want to remove elements from a collection while iterating over it using a for-each loop in Java, you must use an iterator instead of the looping construct.
- How do you remove an array element in a foreach loop?PHP
It is generally not recommended to remove array elements while iterating over the array using a foreach loop, because the loop will behave unexpectedly when elements are removed.