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:
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