-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLab2.php
More file actions
160 lines (143 loc) · 3.54 KB
/
Lab2.php
File metadata and controls
160 lines (143 loc) · 3.54 KB
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
<?php
//Initialization of 5metric array
$arr = array
(
array
(
array
(
array
(
array(123, 123.5, "привет", "hi"),
array(57.4545, "HELLO", 45)
),
array
(
array(13.134, 123.2141245, "привghbет", false),
array("false","Хелло",".")
)
),
array
(
array
(
array(123, 113212323.1231235, "привет", "hiпasd"),
array("asdыфв", 123, "solo", "hфвi")
)
),
array
(
array
(
array(121231233, 1123123123.5e-4, "ТеСт", "hi")
)
)
)
);
//Power of round
define("ST", 2);
//Initialization of constant count of colors and array of colors
define("COUNT", 7);
$rb = array
(
"red", "orange", "yellow", "green", "cyan", "blue", "purple"
);
echo '<table class="lab2">';
//Output of start array
for($l1 = 0; $l1 < count($arr); $l1++) {
echo '<tr class="ex_border">';
for($l2 = 0; $l2 < count($arr[$l1]); $l2++) {
echo '<td class="ex_border">';
echo '<table class="in_table">';
for($l3 = 0; $l3 < count($arr[$l1][$l2]); $l3++) {
echo '<tr class="in_border">';
for($l4 = 0; $l4 < count($arr[$l1][$l2][$l3]); $l4++) {
echo '<td class="in_border">';
for($l5 = 0; $l5 < count($arr[$l1][$l2][$l3][$l4]); $l5++)
echo $arr[$l1][$l2][$l3][$l4][$l5], " ";
echo '</td>';
}
echo'</tr>';
}
echo '</table>';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
echo "<br>";
echo "<br>";
//Index of color
$color = 0;
echo '<table class="lab2">';
for($l1 = 0; $l1 < count($arr); $l1++) {
echo '<tr class="ex_border">';
for($l2 = 0; $l2 < count($arr[$l1]); $l2++) {
echo '<td class="ex_border">';
echo '<table class="in_table">';
for($l3 = 0; $l3 < count($arr[$l1][$l2]); $l3++) {
echo '<tr class="in_border">';
for($l4 = 0; $l4 < count($arr[$l1][$l2][$l3]); $l4++) {
//Make a pointer for easy work
$pt = $arr[$l1][$l2][$l3][$l4];
echo '<td class="in_border">';
$l5 = 0;
while ($l5 < count($pt)) {
//Output unmodified cell's value
//echo $pt[$l5], " ";
//flag that can go on to the next iteration
$fl = true;
//if the cell is int
if (is_int($pt[$l5])) {
unset($pt[$l5]);
$pt=array_values($pt);
$fl = false;
}
//if the cell is float
else if ($fl && is_float($pt[$l5])) {
$pt[$l5] = round($pt[$l5], ST);
echo $pt[$l5], " ";
$fl = false;
$l5++;
}
//if the cell is string
else if ($fl && is_string($pt[$l5])) {
$z=0;
while($z < strlen($pt[$l5])){
if (ord($pt[$l5][$z]) >= ord("а") && ord($pt[$l5][$z]) <= ord("я")){
$help = mb_strtoupper($pt[$l5][$z].$pt[$l5][$z+1]);
//Output exactly russian letters
echo $help;
$pt[$l5][$z] = $help[0];
$z++;
$pt[$l5][$z] = $help[1];
}
//Output english letters
else if (ord($pt[$l5][$z]) >= ord("A") && ord($pt[$l5][$z]) <= ord("z")) {
echo '<span style="color:' . $rb[$color] . '">' . $pt[$l5][$z] . '</span>';
$color = ($color + 1) % COUNT;
}
//If it is a letter
else
echo $pt[$l5][$z];
$z++;
}
echo " ";
$fl = false;
$l5++;
}
//if the cell is another
else
$l5++;
}
echo '</td>';
}
echo'</tr>';
}
echo '</table>';
echo '</td>';
}
echo '</tr>';
}
echo '</table>';
?>