【问题标题】:There's a way to count number of words in a .doc?有一种方法可以计算 .doc 中的字数吗?
【发布时间】:2014-04-24 20:57:27
【问题描述】:

我正在想办法用 php 计算 .doc 文档中的字数。 我什么都得不到。

有人知道这样做的方法吗?我需要统计一个 Word 文档中的字数。

谢谢

【问题讨论】:

标签: php string ms-word


【解决方案1】:

同样的问题,答案很好:PHP - Get a word count from an uploaded Microsoft Word document

您需要:

区分文件类型

$file_name = $_FILES['image']['name'];
$file_extn = end(explode(".", strtolower($_FILES['image']['name'])));

if($file_extn == "doc" || $file_extn == "docx"){
    docx2text();
}elseif($file_extn == "rtf"){
    rtf2text();
}

将文档转换为文本

https://stackoverflow.com/a/7371315/2512934 用于 doc 或 docx http://webcheatsheet.com/php/reading_the_clean_text_from_rtf.php 用于 rtf

数单词http://php.net/manual/en/function.str-word-count.php

我希望这会有所帮助?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-09-06
    • 2020-02-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-17
    • 1970-01-01
    相关资源
    最近更新 更多