Whats is the value of $course?
In somewhere you have to use iconv() function to convert charset of text you want to write to UTF since PHPWord accept only UTF8 as charset and also you have to change setValue function as below
In somewhere you have to use iconv() function to convert charset of text you want to write to UTF since PHPWord accept only UTF8 as charset and also you have to change setValue function as below
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);
}
/*if(!is_array($replace)) {
$replace = utf8_encode($replace);
}*/
$this->_documentXML = str_replace($search, $replace, $this->_documentXML);
}