$nmbrvalues = 11; $position1 = 0; $position2 = 0; $linelength = length($linein); for ($cntr = 1; $cntr <= $nmbrvalues; $cntr++) { $position1 = $position2; $position1 = index($linein,'|',$position1); $position2 = index($linein,'|',$position1 + 1); $fldlength = $position2 - ($position1+1); if ($cntr == 1) {$hold1 = substr($linein,$position1+1,$fldlength);} if ($cntr == 7) {$hold2 = substr($linein,$position1+1,$fldlength);} if ($cntr == 8) {$hold3 = substr($linein,$position1+1,$fldlength);} if ($cntr == 9) { $position3 = $position1+1; $position3 = index($linein,'@',$position3); If ($position3 > 0) { if ($position2 < 0) {$position2 = length($linein);} $fldlength = $position2 - ($position1+1); $emailaddress = substr($linein,$position1+1,$fldlength); } #end of IF if ($position3 <= 0) {$emailaddress = "mgrs\@server.com";} } #end of if } #end of FOR