Top "Foreach" questions

foreach is a looping construct that executes a given piece of code for each element in a list/collection/array.

Counting Values in Multidimensional Array

I currently have the following array: Array( [0] => Array ( [user] => Name 1 [group] => 1 ) [1] => Array ( [user] => Name 2 [group] =&…

php arrays foreach counting
Add a delay after executing each iteration with forEach loop

Is there an easy way to slow down the iteration in a forEach (with plain javascript)? For example: var items = …

javascript loops foreach delay pause
JSTL ForEach Loop/ Array or List

I needed to loop through items but I am also looking for a way to get the next or previous …

foreach jstl foreach-loop-container
glob() — Sort by Name

How can I reverse the sort by filename? Currently it displays all the text files in alphabetical / numerical order, but …

php sorting foreach reverse glob
C#: Any benefit of List<T>.ForEach(...) over plain foreach loop?

I'm wondering why List<T>.ForEach(Action<T>) exists. Is there any benefit/difference in doing : …

c# c#-3.0 foreach
Should I always use Parallel.Foreach because more threads MUST speed up everything?

Does it make sense to you to use for every normal foreach a parallel.foreach loop ? When should I start …

c# .net-4.0 foreach parallel-processing
PowerShell/CLI: "Foreach" loop with multiple arrays

I have a PowerCLI script that powers off a VM, changes its memory and cpu, and then powers it back …

arrays powershell foreach vmware powercli
How to for_each through a list(objects) in Terraform 0.12

I need to deploy a list of GCP compute instances. How do I loop for_each through the "vms" in …

list loops object foreach terraform
Run a program in a ForEach loop

I'm trying to get this simple PowerShell script working, but I think something is fundamentally wrong. ;-) ls | ForEach { "C:\…

powershell foreach pipeline
How do you create a progress bar when using the "foreach()" function in R?

there are some informative posts on how to create a counter for loops in an R program. However, how do …

r foreach progress-bar