PHP: чтение нескольких файлов doc / docx и добавление их в один файл doc - PullRequest
0 голосов
/ 31 августа 2018

Можно ли читать и записывать файлы Word (doc / docx) на PHP и добавлять содержимое в один файл doc / docx?

Я могу сделать это в текстовых файлах. Но не могу разобраться в файлах doc / docx.

<?php
error_reporting(0);
//Name of the directory containing all files to merge
$Dir = "dir";


//Name of the output file
$OutputFile = "output.txt";


//Scan the files in the directory into an array
$Files = scandir ($Dir);


//Create a stream to the output file
$Open = fopen ($OutputFile, "w"); //Use "w" to start a new output file from zero. If you want to increment an existing file, use "a".


//Loop through the files, read their content into a string variable and write it to the file stream. Then, clean the variable.
foreach ($Files as $k => $v) {
    if ($v != "." AND $v != "..") {
        $Data = file_get_contents ($Dir."/".$v);
        fwrite ($Open, $Data);
    }
    unset ($Data);
}


//Close the file stream
fclose ($Open);
?>

Может ли кто-нибудь помочь мне прочитать содержимое нескольких файлов doc / docx и поместить содержимое в один doc / docx ??

...