I want to read the text from a .docx
file line by line and keep the each line data in an array, since .docx
is a zipped file i want to convert it into a .doc
file so that I can read the file using @fopen($filename, 'r');
.
Below is the code I tried using PHPWord to conver from .docx
to .doc
,
<?php
require_once 'phpWord/PHPWord.php';
$PHPWord = new PHPWord();
$document = $PHPWord->loadTemplate('BasicTable.docx');
// Save File
$objWriter = PHPWord_IOFactory::createWriter($PHPWord, 'Word2007');
$objWriter->save('BasicTable4.doc');
?>
and this creates an erroneous .doc
file.
If you want to get the text out of .docx file and save it as a text file then you can use the library docx2text
after converting it to text file you can read the text file line by line and keep each line data in an array.