Monday, 22 June 2015

php program to demonstrate the usage of for each loop

the value of the current array element is assigned to $value and the array pointer is moved by one, until it reaches the last array element.

The following example demonstrates a loop that will output the values of the given array ($fruits):

<?php
$fruits = array("apple", "orange", "mango", "banana");

foreach ($fruits as $value) {
    echo "$value <br>";
}
?>

output


No comments:

Post a Comment