The foreach Statement PHP

An array is a collection of values referenced by keys. The foreach statement retrieves values from an array, one at a time. Like other looping structures, the foreach statement may have a simple or compound statement that's executed each time through the loop. shows the structure of a foreach statement.

The foreach statement

The foreach statement
The foreach statement expects an array, the keyword as, and a definition of the variables to receive each element. If a single value follows as, such as foreach($array as $value), then with each turn of the loop, the variable named value will be set with the value of the next array element. You may capture the index of the array element if you form the foreach statement like foreach($array as $key=>$value).



Face Book Twitter Google Plus Instagram Youtube Linkedin Myspace Pinterest Soundcloud Wikipedia

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

PHP Topics