Как в шаблон .docx добавить html код на php

Подскажите как в шаблон добавить html код который обработаться на выходе в .docx документ по принципу:

$html = $_POST['html'];
$message = str_replace("{tag}", "$html", $message);

Сам код:

if(isset($_POST['ID'])) {
$sql = mysql_query("SELECT * FROM `form_doc` ", $link);
while ($result = mysql_fetch_array($sql)) {
$ghhjj=$result['en']; 
$date = date('d-M-Y H:i:s'); 
$template_file_name = "uploads_doc/$ghhjj";
$fileName = "$rand-$ghhjj";
$folder   = "results/$rand";
$full_path = $folder . '/' . $fileName;
try
{
    if (!file_exists($folder))
    {
        mkdir($folder);
    }       
         
    //Copy the Template file to the Result Directory
    copy($template_file_name, $full_path);
 
    // add calss Zip Archive
    $zip_val = new ZipArchive;
  
    //Docx file is nothing but a zip file. Open this Zip File
    if($zip_val->open($full_path) == true)
    {
        // In the Open XML Wordprocessing format content is stored.
        // In the document.xml file located in the word directory.
         
        $key_file_name = 'word/document.xml';
        $message = $zip_val->getFromName($key_file_name);                
                      
        $timestamp = date('d-M-Y H:i:s');
         
        // this data Replace the placeholders with actual values
 
          $message = str_replace("ID", "$ID",       $message);
 
        //Replace the content with the new content created above.
        $zip_val->addFromString($key_file_name, $message);
        $zip_val->close();
    }
}
catch (Exception $exc) 
{
    $error_message =  "Error creating the Word Document";
    var_dump($exc);
}


}}

Ответы (0 шт):