This is the code I'm using:
public function getAuthorsString($authors) {
$result = "";
if ($authors->exists())
foreach ($authors as $authorKey => $author) {
$result = $result."{$author->ForeName} {$author->SurName}, ";
}
$result = rtrim(trim($result), ",");
return $result;
}
The $authors variable is a DataObjectSet, and this line is the problem:
$result = $result."{$author->ForeName} {$author->SurName}, ";
I also tried:
$result .= "{$author->ForeName} {$author->SurName}, ";
And:
$result = "{$result}{$author->ForeName} {$author->SurName}, ";
None of them work. But if I only assign without maintaining the last value, therefore ultimately returning only the last author:
$result = "{$author->ForeName} {$author->SurName}, ";
It works perfectly fine.
The error I'm getting is this:
error on line 33 at column 266: Encoding error
Please help me, I have no idea what to do.