OkFx.Net, get rebates from your trade

The foreach Statement

The foreach Statement

The foreach statement is used to loop through arrays.

For every loop, the value of the current array element is assigned to $value (and the array pointer is moved by one) - so on the next loop, you’ll be looking at the next element.

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

Example

The following example demonstrates a loop that will print the values of the given array:

<html>
<body>
<?php
$arr=array(”one”, “two”, “three”);
foreach ($arr as $value)
{
echo “Value: ” . $value . “<br />”;
}
?>
</body>
</html>

and output is

Value: one
Value: two
Value: three


Related post :
  • The for Statement
  • PHP If…Else Statements
  • The do…while Statement
  • while Statement
  • How to Use the PHP Include Statement
  • 2 Responses to “The foreach Statement”

    1. Satellite Tv Form Pc Says:

      Do you know of anywhere else that I can get some information about %keyword%? I have come across your post %title% and it has given me some great ideas, but I am looking for some more information about %keyword% any ideas?


      reply
    2. Flora Fleming Says:

      xtmq3v7mtjgyhryv


      reply

    Leave a Reply