PHP-从上载的Microsoft Word文档中获取字数统计 [英] PHP - Get a word count from an uploaded Microsoft Word document
问题描述
我正在尝试从上载的单词文档(.doc, .docx, .rtf)
中获取单词计数,但它始终会执行令人讨厌的Word格式.
I am trying to grab a word count from an uploaded word doc (.doc, .docx, .rtf)
but it always carries through the annoying Word formatting.
有人以前解决过这个问题,知道如何解决吗? 谢谢:)
Anybody tackled this issue before and know how to solve it? Thanks :)
推荐答案
您将需要:
-
区分文件类型
Distinguish the file type
$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();
}
将文档转换为文本
Convert the document to text
用于文档或docx的 https://stackoverflow.com/a/7371315/2512934 http://webcheatsheet.com/php/reading_the_clean_text_from_rtf.php for rtf
https://stackoverflow.com/a/7371315/2512934 for doc or docx http://webcheatsheet.com/php/reading_the_clean_text_from_rtf.php for rtf
算单词 http://php.net/manual/zh/function.str- word-count.php
这篇关于PHP-从上载的Microsoft Word文档中获取字数统计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!