PHP Foreach Loop

Loops through a block of code for each element in an area.


foreach ($array as $value) {
  code to be executed;


The following example will output the values of the given array ($colors):

$colors = array("yellow", "green", "blue", "golden");

foreach ($colors as $value) {
  echo "$value 
"; } ?>

Leave a Reply

Your email address will not be published. Required fields are marked *