如何在php中从Doc文件中获取内容
我在 Yii2 中使用PHPOffice/ PHPWord。
此代码不起作用:(我的文档文件是 UTF8)
$phpWord = \PhpOffice\PhpWord\IOFactory::load($filename, 'MsDoc');
$sections = $phpWord->getSections();
foreach ($sections as $key => $value) {
    $sectionElement = $value->getElements();
    foreach ($sectionElement as $elementKey => $elementValue) {
        if ($elementValue instanceof \PhpOffice\PhpWord\Element\TextRun) {
            $secondSectionElement = $elementValue->getElements();
            foreach ($secondSectionElement as $secondSectionElementKey => $secondSectionElementValue) {
                if ($secondSectionElementValue instanceof \PhpOffice\PhpWord\Element\Text) {
                    echo $secondSectionElementValue->getText() . '<br/>';
                }
            }
        }
    }
}
我需要从 Doc 文件中获取内容(标题,...)