Mark As Completed Discussion

#4 - PHP foreach loop

PHP foreach loop Introduction

PHP foreach loop is an exclusive construct in PHP that iterates over arrays and objects only. It is highly efficient for looping over associative arrays. That’s because it reserves two pointers for accessing the key-value pairs as it loops over the associative array. Here’s the syntax.

foreach($associative_arr as $key=>$value)

The $key and $value get the associative array’s key and values as the loop iterates.

Source

https://www.php.net/manual/en/control-structures.foreach.php

PHP
OUTPUT
:001 > Cmd/Ctrl-Enter to run, Cmd/Ctrl-/ to comment