-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterations.php
More file actions
37 lines (36 loc) · 912 Bytes
/
iterations.php
File metadata and controls
37 lines (36 loc) · 912 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
35
36
37
<?php
//echo "We talk about Iterations(loop)";
// for($i = 0; $i <= 10; $i++) {
// //echo $i == 0 ? "$i" : ": $i";
// echo "i = $i<br>";
// }
$i = 31;
// while($i < 20) {
// echo "i = $i<br>";
// //never ending
// $i = $i + 1;
// }
//do while = "do first", then check
// do {
// echo "ii = $i<br>";
// $i = $i + 1;
// }while($i < 30);
//foreach
$fruits = ['apple', 'pineapple', 'orange', 'lemon'];
/*
for($i = 0; $i < count($fruits); $i++) {
echo "$fruits[$i] <br>";
}
*/
// foreach ($fruits as $index => $fruit) {
// echo "$index - $fruit <br>";
// }
$person = [
'full_name' => 'Nguyen Duc Hoang',
'email' => 'sunlight4d@gmail.com',
'age' => 43
];
foreach($person as $key => $value) {
echo "$key : $value <br>";
}
?>