The foreach construct provides an easy way to iterate over arrays. foreach works only on arrays and objects.
<?php
foreach (array_variable as value)
{
code to be execute]
}
?>
<?php
$x=array("Tutorials","Computer","Online Tools");
foreach($x as $value)
{
echo $value."
";
}
?>
Tutorials
Computer
Online Tools