I managed to do it like this:
global $comma_separated;
if (in_array($lin[1], $_SESSION['name'])){
$arrayr = array($lin[1]);
$comma_separated .= implode(",", $arrayr);
then further down out side the loop in my form I have:
<input type='text' name='hiddenField1' value='$comma_separated'>
which prints 'example1example2example3' in the form whcih is great :-)
All I have left to do is to work out how to add a space in between.