ok, first of all, I need to validate the contents of an array. If there are any "errors" I need to report those "errors" (the contents of the array) to a text file along with the date and time the errors were written. I need to use a loop function to go through the array and pick out any errors. Anyone have an idea of which loop I could use? I tried using the for() loop but that didn't work because it didn't know when to stop. it needs to be in 2 pages. Here's what I've got so far: <?php //page3.php if ($_GET['filename']) { $file = "./courses/".$_GET['filename']; if (file_exists($file)){ $readfile = file($file); foreach ($readfile as $string) { list($num, $last, $first, $email) = explode(',', $string); } //insert loop here ( require_once("./page4.php"); isStudentNumberWellFormed($num); //isEmailAddressWellFormed($email); } }else { echo "no such file, sorry"; } } else { die('must specify filename'); } ?> PHP: <?php //page4.php function isStudentNumberWellFormed ($studentnumber){ if(!eregi("^a[0-9]{8}$", $studentnumber)){ $openfile = fopen("courses/errors.log", "a+"); $date_time = date("F d, Y (h:i:s a)"); $error = $date_time . $studentnumber; fwrite($openfile, $error); fclose($openfile); $error "Errors have been found in ".$_GET['filename']. ".A report, errors.log has been generated"; return $error; } else{ $numberokay = "Error in string format"; return $numberokay; } } ?> PHP: Any help is appreciated Thanks - Derek
You already have a foreach() loop, which should be file. Just put the validation code inside the loop. Right under the list() statement.