Forum


Replies: 1   Views: 2770
Problem with searchandreplace()
Topic closed:
Please note this is an old forum thread. Information in this post may be out-to-date and/or erroneous.
Every phpdocx version includes new features and improvements. Previously unsupported features may have been added to newer releases, or past issues may have been corrected.
We encourage you to download the current phpdocx version and check the Documentation available.

Posted by Limman  · 30-01-2017 - 16:46

Hello. I have a problem with replacing text in a document. The space after the replaced phrase disappears.

<?php

require_once '/classes/DocxUtilities.inc';

$docx = new DocxUtilities();
$options = array(
                'document'                       => true,
                'endnotes'                       => true,
                'comments'                       => true,
                'headersAndFooters'  => true,
                'footnotes'     => true,
);

$search = '$Larue HAFFAR$';
$replace = '$Grace WEKLEY$';

$docx->searchAndReplace('error.docx', 'out.docx', $search, $replace, $options);

Document: https://dl.dropboxusercontent.com/u/47221682/phpdocx/error.docx

Images:
Original: https://dl.dropboxusercontent.com/u/47221682/phpdocx/original.png
Replaced: https://dl.dropboxusercontent.com/u/47221682/phpdocx/replaced.png