-
Notifications
You must be signed in to change notification settings - Fork 0
/
第六次作业结果.html
227 lines (227 loc) · 8.5 KB
/
第六次作业结果.html
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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
<!DOCTYPE html>
<html lang="en">
<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></style>
</head>
<body>
<div id="one">
<h1>数组排序1</h1>
使用sort()对数组$arr1排序,使用print_r ()输出数组观察结果,输出最小值:44
<br />
<hr />
使用rsort()对数组$arr1排序,使用print_r ()输出数组观察结果,输出最大值:99
<br />
<hr />
使用asort()对数组$arr1排序,使用print_r ()输出数组观察结果:Array ( [9] =>
44 [8] => 56 [7] => 64 [6] => 74 [5] => 77 [4] => 87 [3] => 89 [2] => 96
[1] => 98 [0] => 99 )
<br />
<hr />
使用arsort()对数组$arr1排序,使用print_r ()输出数组观察结果:Array ( [9] =>
44 [8] => 56 [7] => 64 [6] => 74 [5] => 77 [4] => 87 [3] => 89 [2] => 96
[1] => 98 [0] => 99 )
<br />
<hr />
删除数组头部1个元素,使用print_r ()输出数组观察结果:Array ( [0] => 56 [1]
=> 64 [2] => 74 [3] => 77 [4] => 87 [5] => 89 [6] => 96 [7] => 98 [8] =>
99 )
<br />
<hr />
删除数组尾部1个元素,使用print_r ()输出数组观察结果:Array ( [0] => 56 [1]
=> 64 [2] => 74 [3] => 77 [4] => 87 [5] => 89 [6] => 96 [7] => 98 )
<br />
<hr />
使用shuffle()对数组$arr1排序,使用print_r ()输出数组观察结果:Array ( [0]
=> 96 [1] => 87 [2] => 98 [3] => 89 [4] => 56 [5] => 77 [6] => 74 [7] =>
64 )
<br />
</div>
<div id="two">
<h2>数组排序2</h2>
使用array_reverse()使元素顺序相反的数组,使用print_r ()输出观察结果:
<br />
<hr />
Array ( [name] => Volvo [city] => BMW [country] => Toyota )
<br />
使用ksort()对数组$arr2排序,使用print_r ()输出数组观察结果:
<br />
<hr />
Array ( [city] => BMW [country] => Toyota [name] => Volvo )
<br />
使用krsort()对数组$arr2排序,使用print_r ()输出数组观察结果:
<br />
<hr />
Array ( [name] => Volvo [country] => Toyota [city] => BMW )
</div>
<div id="three">
<h1>数组检索</h1>
使用array_keys(),查找'60'所对应的键,使用print_r ()输出观察结果
<br />
Array ( [0] => 张三 [1] => 赵六 [2] => 孙七 )
<hr />
使用array_keys(),使用严格模式查找'60'所对应的键,输出值为'60'的个数
<br />
2
<hr />
使用array_values()获取数组中的所有值
<br />
Array ( [0] => 60 [1] => 50 [2] => 40 [3] => 60 [4] => 60 )
<hr />
使用array_search(),查找'60'所对应的键,输出观察结果
<br />
张三
<hr />
使用array_search(),使用严格模式查找数组是否存在40,输出观察结果
<br />
<pre class="xdebug-var-dump" dir="ltr">
<small>C:\wamp64\www\PHP\第六次作业\数组检索.php:28:</small><small>boolean</small> <font color='#75507b'>true</font>
</pre>
<hr />
使用in_array(),查找40值是否在数组,输出结果
<br />
<pre class="xdebug-var-dump" dir="ltr">
<small>C:\wamp64\www\PHP\第六次作业\数组检索.php:33:</small><small>boolean</small> <font color='#75507b'>true</font>
</pre>
<hr />
使用in_array(),查找40值是否在数组,输出结果
<br />
<pre class="xdebug-var-dump" dir="ltr">
<small>C:\wamp64\www\PHP\第六次作业\数组检索.php:38:</small><small>boolean</small> <font color='#75507b'>true</font>
</pre>
<hr />
使用array_key_exists,查找“张三”键是否在数组,输出结果
<br />
<pre class="xdebug-var-dump" dir="ltr">
<small>C:\wamp64\www\PHP\第六次作业\数组检索.php:43:</small><small>boolean</small> <font color='#75507b'>true</font>
</pre>
<hr />
将$arr3数组使用array_chunk()拆分成2个数组,保留原来的键名,使用print_r打印输出数组
<br />
<pre class="xdebug-var-dump" dir="ltr">
<small>C:\wamp64\www\PHP\第六次作业\数组检索.php:48:</small>
<b>array</b> <i>(size=2)</i>
0 <font color='#888a85'>=></font>
<b>array</b> <i>(size=3)</i>
'张三' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'60'</font> <i>(length=2)</i>
'李四' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'50'</font> <i>(length=2)</i>
'王五' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'40'</font> <i>(length=2)</i>
1 <font color='#888a85'>=></font>
<b>array</b> <i>(size=2)</i>
'赵六' <font color='#888a85'>=></font> <small>string</small> <font color='#cc0000'>'60'</font> <i>(length=2)</i>
'孙七' <font color='#888a85'>=></font> <small>int</small> <font color='#4e9a06'>60</font>
</pre>
<hr />
</div>
<div id="four">
<h1>生成验证码</h1>
<h6>
暂时php的代码还不能远程执行,所以我用js重构了下 --
重构的差不多了,还差颜色
</h6>
<div style="color: red">
<span
style="
margin-right: 6px;
color: #ec7034;
font-size: 20px;
transform: rotateX(13deg) rotateY(54deg) rotateZ(54deg)
rotate3d(1, 1, 1, 28deg);
display: inline-block;
">
r
</span>
<span
style="
margin-right: 6px;
color: #215ff1;
font-size: 28px;
transform: rotateX(17deg) rotateY(-36deg) rotateZ(4deg)
rotate3d(1, 1, 1, 30deg);
display: inline-block;
">
A
</span>
<span
style="
margin-right: 6px;
color: #02efc3;
font-size: 29px;
transform: rotateX(38deg) rotateY(-35deg) rotateZ(-9deg)
rotate3d(1, 1, 1, 27deg);
display: inline-block;
">
i
</span>
<span
style="
margin-right: 6px;
color: #ec2791;
font-size: 35px;
transform: rotateX(22deg) rotateY(36deg) rotateZ(-6deg)
rotate3d(1, 1, 1, 25deg);
display: inline-block;
">
N
</span>
<span
style="
margin-right: 6px;
color: #e9659d;
font-size: 29px;
transform: rotateX(-22deg) rotateY(14deg) rotateZ(3deg)
rotate3d(1, 1, 1, 21deg);
display: inline-block;
">
c
</span>
<span
style="
margin-right: 6px;
color: #ae5baa;
font-size: 20px;
transform: rotateX(18deg) rotateY(18deg) rotateZ(36deg)
rotate3d(1, 1, 1, 22deg);
display: inline-block;
">
B
</span>
</div>
<div id="code"></div>
</div>
</body>
<script>
//稍等老师,我先想下怎么重构 --- 完成90%
const code = document.getElementById("code");
function codeFun() {
const characters =
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
let random_string = "";
for (let i = 0; i < 6; i++) {
let index = Math.floor(Math.random() * (characters.length - 0));
random_string += characters[index];
}
const div = document.createElement("div");
for (let i = 0; i < random_string.length; i++) {
let $color = `rgba(${Math.floor(Math.random() * 256)},${Math.floor(
Math.random() * 256
)},${Math.floor(Math.random() * 256)},1)`;
let $fontSize = Math.floor(Math.random() * (36 - 18) + 18) + "px";
let $rotateX = Math.floor(Math.random() * (20 - 10) + 10) + "deg";
let $rotateY = Math.floor(Math.random() * (20 - 10) + 10) + "deg";
let $rotateZ = Math.floor(Math.random() * (50 - 40) + 40) + "deg";
let $rotate3D = Math.floor(Math.random() * (60 - 20) + 20) + "deg";
const span = document.createElement("span");
span.innerHTML = random_string[i];
span.style = `margin-right:6px;color:${$color};font-size: ${$fontSize};transform: rotateX(${$rotateX}) rotateY(${$rotateY}) rotate3d(1,1,1,${$rotate3D}); display:inline-block`;
div.appendChild(span);
}
return div;
}
code.appendChild(codeFun());
codeFun();
</script>
</html>