-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path9 Loops.php
More file actions
34 lines (33 loc) · 711 Bytes
/
9 Loops.php
File metadata and controls
34 lines (33 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!-- PHP Loops -->
<title>PHP Loops</title>
<?php
#While Loop
$number = 1;
while ($number <= 10) {
echo $number . "<br>";
$number++;
}
echo "<hr>";
#Do While Loop
$number = 10;
do {
echo $number . "<br>";
$number += 10;
} while ($number <= 100);
echo "<hr>";
#For Loop
for ($number = 11; $number <= 99; $number += 11) {
echo $number . "<br>";
}
echo "<hr>";
#Foreach Loop
$colors = array("Red", "Green", "Blue", "Black", "White");
foreach ($colors as $value) {
echo "$value <br>";
}
echo "<br>";
$fruitsPrice = array("Papaya" => "85", "Apple" => "280", "Grapes" => "60", "Orange" => "100", "Mango" => "50");
foreach ($fruitsPrice as $key => $value) {
echo "$key : $value <br>";
}
?>