forked from hanlintao/translatorscanprogram
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path代码 7-5.php
More file actions
31 lines (30 loc) · 1.42 KB
/
代码 7-5.php
File metadata and controls
31 lines (30 loc) · 1.42 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
<?php include "shared/head.php"; ?>
<form action="" method="POST">
<table>
<tr>
<td><textarea rows="10" name ="text">北京语言大学(Beijing Language and Culture University, BLCU)成立于1962年。</textarea></td>
</tr>
<tr>
<td><button type="submit">开始统计</button></td>
</tr>
</table>
</form>
<?php
$text=$_POST["text"];
echo "英文单词个数为:".str_word_count($text)."<br>";
echo "英文单词包括:";
$english_char_num="";
foreach(str_word_count($text,1) as $english)
{
$english_char_num = $english_char_num + strlen($english);
echo $english." ";
}
echo "<br>"."英文单词字符总数为:".$english_char_num."<br>";
echo "全文空格个数为:".substr_count($text," ")."<br>";
$chinese_punct= ",。、!?:;﹑•"…‘’“”〝〞∕¦‖— 〈〉﹞﹝「」‹›〖〗】【»«』『〕〔》《﹐¸﹕︰﹔!¡?¿﹖﹌﹏﹋'´ˊˋ―﹫︳︴¯_ ̄﹢﹦﹤‐¬˜﹟﹩﹠﹪﹡﹨﹍﹉﹎﹊ˇ︵︶︷︸︹︿﹀︺︽︾ˉ﹁﹂﹃﹄︻︼()";
$pattern = array("/[[:punct:]]/i", "/['.$chinese_punct.']/u", "/[[:alnum:]]/", "/[[:space:]]/",);
$chinese = preg_replace($pattern, '', $text);
echo "中文文本包括:".$chinese."<br>";
echo "中文字数为:".mb_strlen($chinese, "utf8")."<br>";
?>
<?php include "shared/foot.php"; ?>