I want to separate iteration results by comma, but it's not an array. I want to do it in views, so code shouldn't be long.
<?php foreach ($roles as $role): ?>
<?php echo $role->title; ?>
<?php endforeach; ?>
Result object implements Countable, Iterator, SeekableIterator, ArrayAccess.
Not certain I understand what your asking (your code basically seems to do what you say?) the only thing i see missing is separate by comma.
Or if caching is ok (string length isn't too long):