Top "Foreach" questions

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

How to go to next record in foreach loop

foreach ($arr as $a1){ $getd=explode(",",$a1); $b1=$getd[0]; } In above code, if that $getd[0] is empty i want to …

php loops foreach explode
Is there a difference between foreach and map?

Ok this is more of a computer science question, than a question based on a particular language, but is there …

foreach language-agnostic computer-science map-function
How do you loop through $_FILES array?

Here are the inputs I want to loop through Main photo: <input type="file" name="image[]" /> Side photo 1: &…

php loops input foreach form-processing
How to add loop counter to foreach in csh

In CSH foreach loop or for loop, how can I add a loop iterator or counter which increases from 10 to 1000 …

loops foreach counter csh
while(list($key, $value) = each($array)) vs. foreach($array as $key => $value)?

Recently I experienced this weird problem: while(list($key, $value) = each($array)) was not listing all array values, where replacing …

php arrays loops foreach while-loop
Qt foreach loop ordering vs. for loop for QList

When iterating through a QList<T> with a foreach loop, in the tests I conducted the items are …

c++ qt for-loop foreach qt4
php PDO fetchAll() - while not working, foreach works

I would like to know if i'm doing fine OR fetchAll() doesn't work with WHILE. here is an exemple $db=…

php pdo foreach while-loop fetchall
use xsl to output plain text

I needed to use XSL to generate simple plain text output from XML. Since I didn't find any good, concise …

xml xslt foreach plaintext line-breaks
Javascript efficiency: 'for' vs 'forEach'

What is the current standard in 2017 in Javascript with for() loops vs a .forEach. I am currently working my way …

javascript loops for-loop foreach
How to read from files with Files.lines(...).forEach(...)?

I'm currently trying to read lines from a text only file that I have. I found on another stackoverflow(Reading …

java file foreach filereader line-by-line