php for statement code example
Example 1: for loop php
<?php
$fruits = ["apple", "banana", "orange"];
for($i=0;$i<count($fruits);$i++){
echo "Index of ".$i."= ".$fruits[$i]."<br>";
}
?>
Example 2: php for loop
for($i = 0; $i <=10; $i++){
echo "The index is $i";
}
Example 3: for php
<?php
$fruits = ["apple", "banana", "orange"];
for ($i = 0; $i < count($fruits); $i++) {
echo "Index of ".$i."= ".$fruits[$i]."<br>";
}
$i = 0;
foreach ($fruits as $value) {
echo "Index of ".$i."= ".$value."<br>";
$i++;
}
?>
Example 4: php for next loop step
for ($i = 0; $i < 10; ++$i)
{
echo "I will loop 10 times";
}