phpword读取word的文本内容

use PhpOffice\PhpWord\PhpWord;
use PhpOffice\PhpWord\IOFactory;

$info = public_path().'/uploads/admin/examination/test.docx';
$phpWord = new PhpWord();
$sections =IOFactory::load($info)->getSections();

foreach($sections as $section) {

  $elements = $section->getElements();
  foreach($elements as $element) {

    echo $element->getElements()[0]->getText() . "\n";
  }
}

posted @ 2020-04-03 23:43  程序员小艺  阅读(5242)  评论(0)    收藏  举报