loop php
snippet in php

php loop

user4900


<?php 
for ($x = 0; $x <= 10; $x++)
{

   echo "The number is: $x <br>";
} 
?>  

for loop php

user8904

<?php
	$fruits = ["apple", "banana", "orange"];
	for($i=0;$i<count($fruits);$i++){
    echo "Index of ".$i."= ".$fruits[$i]."<br>";
    }
  ?>

loop php

user5983

for ($x = 0; $x <= 10; $x++) {
     echo "The number is: $x <br>";
} 

for loop in php

user4570

/*
For loop in php
*/

<?php
for ($i = 0; $i < 10; $i++) {
     echo $i."<br>";
} 
?>

how create loop php

user1407

while (condition) {
   code to be executed;
}
//Example
<?php
   $i = 0;
   $num = 50;
   
   while( $i < 10) {
      $num--;
      $i++;
   }
   
   echo ("Loop stopped at i = $i and num = $num" );
?>
//...................................
foreach (array as value) {
   code to be executed;
}
//Example
<?php
  $array = array( 1, 2, 3, 4, 5);
  
  foreach( $array as $value ) {
     echo "Value is $value <br />";
  	}
?>