while loop php
snippet in php

php loop

user9049


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

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

while loop php

user8910

<?php
	$a = 0;
	while($a<=5){
    	echo $a."<br>";
      $a++;
    }
  ?>

php while loop array

user8698


<?php  
$x = 1;
 
while($x <= 5) {
  echo "The number is: $x <br>";
  $x++;
} 
?>  

php loops

user8087

#Loops

<?php
    #loops execute code a set number of times
    /*
    Types of loops
    1-For
    2-While
    3-Do..while
    4 Foreach
    */

    # For Loop usually use if you know the number of times it has to execute
    # @params -it takes an init, condition, increment
    #for($i =0;$i<=11;$i++){
    #echo 'Number: '.$i;
    #echo '<br>';
    #}
    #While loop
    # @ prams - condition
    #$i = 0;
    #while($i < 10){
    #    echo $i;
    #    echo '<br>';
    #    $i++;
    #}
    # Do...while loops
    #@prapms - condition
    /*$i = 0;
    do{
        echo $i;
        echo '<br>';
        $i++;
        }
        while($i < 10);*/
    # Foreach  --- is for arrays
    
    # $people = array('Brad', 'Jose', 'William');
    #     foreach($people as $person){
    #     echo $person;
    #     echo '<br>';
    # }
    $people = array('Tony' => 'tony@example.com',
        'Jose' => 'jose@example.com','William' => 'William@example.com');
    
     foreach($people as $person => $email){
        echo $person.': '.$email;
        echo '<br>';
}
?>

while true php

user5334

while(true) {
 // Infinite Loop
}

while in php

user9193

<?php
  echo 'nice';
?>