PHP Programs

program using for each statement

In this program we demonstrate use of for each loop.  how to use for each loop in program we will see in this program

Program

<html>

<body>

<?php

$array=array(1,2,3,4,5);

foreach($array as $value)

{

  echo"value is $value <br/>";

}

?>

</body>

</html>

When Run The Program Following Output:

value is 1

value is 2

value is 3

value is 4

value is 5

Description

For each loop is used for iterate through array values

Syntax of for each loop :

 

foreach($variable  as $arr_values)

{

block of code to be executed

}

Releted Programs

© 2017 codewmAll rights reserved.