What is foreach loop? | SoloLearn: Learn to code for FREE!


What is foreach loop?


6/2/2017 5:47:56 AM

Vismay Katharani

2 Answers

New Answer



Example: $read = file('names.txt'); foreach ($read as $line) { echo $line .", "; } For example, if you have a file and you want to read every single line. And then you want to echo it out into world. $read is the file and $line is every line. You also can use it for arrays. Maybe this could help you.