-
Notifications
You must be signed in to change notification settings - Fork 0
/
loop.php
168 lines (142 loc) · 4.51 KB
/
loop.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html lang="en">
<?php
$header_footer_bgcolor = "rgb(14, 14, 14)";
$body_color = "#ddd";
$shadow_color = "rgb(146, 135, 135)";
?>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
body,html {
background-color: #ffffff;
height:100%;
}
.container {
width:900px;
margin: 0 auto;
position: relative;
text-align: center;
border: 3px <?php echo $shadow_color ?>;
border-radius: 5px;
box-shadow: 2px 3px 5px <?php echo $shadow_color ?>;
background-color: <?php echo $body_color ?>;
}
.header {
padding: 10px;
background-color: <?php echo $header_footer_bgcolor ?>;
top: 0px;
box-shadow: 2px 3px 5px <?php echo $shadow_color ?>;
}
.footer {
padding: 20px;
background-color: <?php echo $header_footer_bgcolor ?>;
bottom: 0px;
width: 95.70%;
font-size: 8px;
font-family: cursiva-monotype;
font-style: italic;
box-shadow: 2px 3px 5px <?php echo $shadow_color ?>;
}
h1 {
color: black;
}
.Body {
padding: 30px 10px;
text-align:left;
}
</style>
</head>
<body>
<div class="container">
<!-- Header start -->
<div class="header">
<h1 style="color: white;">PHP Loop Demo</h1>
</div>
<!-- Body Start -->
<div class="Body">
<h2>For Loop :</h2>
<?php
$numbers = array(2,3,4,5,6);
echo "1D Array Numbers are : ";
for($i = 0; $i<count($numbers);$i++){
echo $numbers[$i];
echo ", ";
}
?>
<h1></h1>
<h2>For Each Loop :</h2>
<?php
$numbers = array(2,3,4,5,6);
echo "1D Array Numbers are : ";
foreach($numbers as $n){
echo $n;
echo ", ";
}
?>
<h1></h1>
<h2>While Loop :</h2>
<?php
$numbers = array(
array(2,4),
array(5,6)
);
$len = count($numbers);
echo "2D Array Numbers are : </br>";
echo " <h1></h1>";
$row = 0;
while($row < $len){
echo "| ";
$col = 0;
while($col < $len){
echo $numbers[$row][$col];
if($col == $len-1){
echo " |</br>";
}else{
echo " ";
}
$col++;
}
$row++;
}
?>
<h1></h1>
<h2>Do While Loop:</h2>
<?php
$numbers = array(
array(2,4,6),
array(5,6,8),
array(9,6,3),
);
$len = count($numbers);
echo "3D Array Numbers are : </br>";
echo " <h1></h1>";
$row = 0;
do{
echo "| ";
$col = 0;
do{
echo $numbers[$row][$col];
if($col == $len-1){
echo " |</br>";
}else{
echo " ";
}
$col++;
}while($col < $len);
$row++;
}while($row < $len);
?>
<h1></h1>
</div>
<!-- Body End -->
<!-- Footer start -->
<div class="footer">
<h1 style="color: white;">Learn with fair Powered by Rahatul Rabbi</h1>
</div>
</div>
</body>
</html>