SetValue and Space

Aug 1, 2014 at 2:03 PM
Edited Aug 1, 2014 at 2:04 PM
Dears,

I'm trying to use SetValue to replace a string with one or double spaces, for example:
$vazio = "  ";
$document->setValue('EXAMPLE', $vazio);
But, in the Word file it generates a null char.
For example:
(${example})
It should be:
(  )
Although, it generates:
()
Anyone capable of helping me?

Thanks :)

BTW, I had to use a "fix" for template.php from phpword, because it was not replacing anything (I think it was generating a wrong XML file and PHPWord couldn't find the necessary string to replace):
public function setValue($search, $replace) {
        if(substr($search, 0, 2) !== '${' && substr($search, -1) !== '}') {
            $search = '${'.$search.'}';
        }
        
        preg_match_all('/\$[^\$]+?}/', $this->_documentXML, $matches);
        
        for ($i=0;$i<count($matches[0]);$i++){

        $matches_new[$i] = preg_replace('/(<[^<]+?>)/','', $matches[0][$i]);
        
        $this->_documentXML = str_replace($matches[0][$i], $matches_new[$i], $this->_documentXML);
        }


                
        
    $this->_documentXML = str_replace($search, $replace, $this->_documentXML);
        
        
        
    }