I am attempting to use a function to check for a valid email address before being read in. I am attempting to use a function as well and this is something I don't have a lot of experience in. Does the following code look correct? In addition to the test.csv I have 3 other email lists being read in. Would I just do the same code for those as well?

# Test
	$testList = "";
	$fileID = "Test.csv";
        $handle = fopen($fileID, "r");
	if ($handle) {
		while (!feof ($handle)) {
			$buffer = fgets ($handle, 4096);
			$buffer = substr ($buffer, 0, -2);
			list ($a, $b, $c, $d, $e, $f) = split (",", $buffer, 6);
	function validEmail($e){
    $pattern = "/^[a-zA-Z0-9-_\.]+@{1}[a-zA-Z0-9-\.]+\.{1}[a-zA-Z]{2,4}$/"; //email 
      		if(preg_match($pattern, $e)){
      		 return true;
     		 return false;
 	 if(validEmail($e) == true){
           		$testList = $testList . $e . " ";
          		echo "Invalid Email Address ".$e;


Your validation is fine. And you can use the same for all 3 files that you want to read.

Thanks for the input...much appreciated.