$phpWord = new \PhpOffice\PhpWord\PhpWord();
// Add a section (in Word all the text is divided into sections)
$section = $pw->addSection();
// Add our HTML section
$html = $_POST['content'] ?? ";
\PhpOffice\PhpWord\Shared\Html::addHtml($section, $html, false, false);
// Save the file
$pw->save("html-to-doc.docx", "Word2007");
Find more questions by tags PHP