getItems() as $item) { $data[] = $item->toArray(); } $text = print_r($data, true); // Remove invalid non-UTF8 characters ini_set('mbstring.substitute_character', 'none'); $text = mb_convert_encoding($text, $this->getCharset(), 'UTF-8'); return $text; } }