mirror of
https://gitee.com/koogua/course-tencent-cloud.git
synced 2025-06-29 22:01:38 +08:00
字数统计加上图片字数
This commit is contained in:
parent
0a86fc3f05
commit
51de0ed94b
@ -14,13 +14,15 @@ class Word
|
|||||||
|
|
||||||
public static function getWordCount($str)
|
public static function getWordCount($str)
|
||||||
{
|
{
|
||||||
|
$imageWordCount = self::getImageWordCount($str);
|
||||||
|
|
||||||
$chineseWordCount = self::getChineseWordCount($str);
|
$chineseWordCount = self::getChineseWordCount($str);
|
||||||
|
|
||||||
$str = self::filterChineseWords($str);
|
$str = self::filterChineseWords($str);
|
||||||
|
|
||||||
$englishWordCount = self::getEnglishWordCount($str);
|
$englishWordCount = self::getEnglishWordCount($str);
|
||||||
|
|
||||||
$count = $chineseWordCount + $englishWordCount;
|
$count = $imageWordCount + $chineseWordCount + $englishWordCount;
|
||||||
|
|
||||||
return (int)$count;
|
return (int)$count;
|
||||||
}
|
}
|
||||||
@ -54,6 +56,11 @@ class Word
|
|||||||
return (int)$count;
|
return (int)$count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getImageWordCount($str)
|
||||||
|
{
|
||||||
|
return 100 * substr_count($str, '<img');
|
||||||
|
}
|
||||||
|
|
||||||
public static function filterChineseWords($str)
|
public static function filterChineseWords($str)
|
||||||
{
|
{
|
||||||
return preg_replace(self::CHINESE_PATTERN, '', $str);
|
return preg_replace(self::CHINESE_PATTERN, '', $str);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user