Array to Single Variable

//Get a form filling from an array and compile in to a single variable with a splitter
//Array to Single Variable

if ($fldUserName) {
$MyUserName="";
foreach (
$fldUserName as $key => $val) {
if (
$fldUserName[$key]) {
if (
$MyUserName) {
$MyUserName = $MyUserName . "|" . $fldUserName[$key];
}else{
$MyUserName = $fldUserName[$key];
}
}
}
}
?>