if ($i == 0 || $i == count($documentSymbol) || $documentSymbolValue == '<')
is almost always true.
I modified the code in similar way as mquadrat:
$documentSymbol = explode(self::$_templateSymbol, self::$_document);
foreach ($documentSymbol as $i => $documentSymbolValue)
if ($i % 2 != 0)
$variables['document'] = strip_tags($documentSymbolValue);
Please let us know what was the reason you prepared the condition in such form, so we can be sure that our modifications won't break other functionality?
I am using latest PHPDocx PRO version 2.7