To read and replace content from Doc file, you can use PHPWord package and download this package using composer command:
composer require phpoffice/phpword
1) Open document
$template = new \PhpOffice\PhpWord\TemplateProcessor('YOURDOCUMENTPATH');
2) Replace string variables for single
$template->setValue('variableName', 'MyVariableValue');
3) Replace string variables for multi occurrence
$template->cloneRow('arrayName', count($array));
– Replace variable value
for($number = 0; $number < count($array); $number++) {
$template->setValue('arrayName#'.($number+1), htmlspecialchars($array[$number], ENT_COMPAT, 'UTF-8'));
}
4) Save the changed document
$template->saveAs('PATHTOUPDATED.docx');
UPDATE
You can pass limit as third parameter into $template->setValue($search, $replace, $limit)
to specifies how many matches should take place.