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
|
<?php
header(
"Content-type:text/html;CharSet=utf-8"
);
$file
=
fopen
(
"sqlstr.txt"
,
"r"
);
$sql_arr
=
array
();
$i
=0;
//输出文本中所有的行,直到文件结束为止。
while
(!
feof
(
$file
))
{
$sql_arr
[
$i
]=
fgets
(
$file
);
//fgets()函数从文件指针中读取一行
$i
++;
}
fclose(
$file
);
$sql_arr
=
array_filter
(
$sql_arr
);
//此处用变量$bianliang1来标识第一个数组
$bianliang1
=
'aaa'
;
foreach
(
$sql_arr
as
$k
=> &
$v
) {
$newarr
[
$k
] =
explode
(
$bianliang1
,
$v
);
}
//此处用变量$bianliang1来标识第二个数组
$bianliang2
=
'bbb'
;
foreach
(
$newarr
as
$k
=> &
$v
) {
if
(!
empty
(
$v
[1])){
$newtwo
[
$k
] =
explode
(
$bianliang2
,
$v
[1]);
}
}
foreach
(
$newtwo
as
$k
=> &
$v
) {
$aaa
[] =
$v
[0];
}
$i
=
count
(
$aaa
);
$ok
=
array_count_values
(
$aaa
);
arsort(
$ok
);
echo
'<pre>'
;
echo
"共"
.
$i
.
"条"
;
echo
'<br>'
;
print_r(
$ok
);
?>
|
本文转自 IT阿飞 51CTO博客,原文链接:http://blog.51cto.com/itafei/1970274