我用 PHPWord 库读取 word 文件
$objReader = \PhpOffice\PhpWord\IOFactory::createReader('Word2007');
$phpWord = $objReader->load($_FILES["fileToUpload"]['tmp_name'], "UTF-8");
foreach ($phpWord->getSections() as $section) {
$arrays = $section->getElements();
foreach ($arrays as $e) {
if (get_class($e) === 'PhpOffice\PhpWord\Element\TextRun') {
foreach($e->getElements() as $text) {
echo $text->getText();
}
}
}
问题是我无法检测到 EOF 字符,我花了很多时间来解决这个问题,但根本没有工作。