PHP Learning : Foreach loop - Publik Talk

Breaking

An informative website for every one.

Post Top Ad

Post Top Ad

Wednesday, August 2, 2017

PHP Learning : Foreach loop

Description:

The foreach loop works only on arrays, and is used to loop through each key/value pair in an array.
For every loop iteration, 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.

Code:

<?php
$x=array("one","two","three");
foreach($x as $value)
{
echo $value."<br />";
}
?>



Output:


No comments:

Post a Comment

Post Top Ad