Answers for "php for loop in html"

PHP
10

for loop php

<?php
	$fruits = ["apple", "banana", "orange"];
	for($i=0;$i<count($fruits);$i++){
    echo "Index of ".$i."= ".$fruits[$i]."<br>";
    }
  ?>
Posted by: Guest on December-28-2019
6

for loop in php

/*
For loop in php
*/

<?php
for ($i = 0; $i < 10; $i++) {
     echo $i."<br>";
} 
?>
Posted by: Guest on May-06-2020
0

how create loop php

for (initialization; condition; increment){
   code to be executed;
}
//Example
<?php
    $a = 0;
    $b = 0;
 for( $i = 0; $i<5; $i++ )
    {
        $a += 10;
        $b += 5;
    }    
echo ("At the end of the loop a = $a and b = $b" );
?>
//.......................................//
  do {
   code to be executed;
}
while (condition);
//Example
<?php
     $i = 0;
    $num = 0;
         
  do {
       $i++;
     }
         
  while( $i < 10 );
 echo ("Loop stopped at i = $i" );
?>
Posted by: Guest on February-24-2020

Browse Popular Code Answers by Language