1#Loops
2
3<?php
4 #loops execute code a set number of times
5 /*
6 Types of loops
7 1-For
8 2-While
9 3-Do..while
10 4 Foreach
11 */
12
13 # For Loop usually use if you know the number of times it has to execute
14 # @params -it takes an init, condition, increment
15 #for($i =0;$i<=11;$i++){
16 #echo 'Number: '.$i;
17 #echo '<br>';
18 #}
19 #While loop
20 # @ prams - condition
21 #$i = 0;
22 #while($i < 10){
23 # echo $i;
24 # echo '<br>';
25 # $i++;
26 #}
27 # Do...while loops
28 #@prapms - condition
29 /*$i = 0;
30 do{
31 echo $i;
32 echo '<br>';
33 $i++;
34 }
35 while($i < 10);*/
36 # Foreach --- is for arrays
37
38 # $people = array('Brad', 'Jose', 'William');
39 # foreach($people as $person){
40 # echo $person;
41 # echo '<br>';
42 # }
43 $people = array('Tony' => 'tony@example.com',
44 'Jose' => 'jose@example.com','William' => 'William@example.com');
45
46 foreach($people as $person => $email){
47 echo $person.': '.$email;
48 echo '<br>';
49}
50?>