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

+5

What is foreach loop?

php

6/2/2017 5:47:56 AM

Vismay Katharani

2 Answers

New Answer

+7

+2

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.