Here's what I've got now. Current problem is with creating or reading the $new_lines array. Can't figure out how the data is seperated. Comma? Space? Pipe? I don't know. When I count it and print out the value it returns 1. When I print the array it says Array.
<?
$data_file = "count.txt";
$timeout = "1800";
$visitor_ip = getenv('REMOTE_ADDR');
$time_now = time();
$file = fopen($data_file, "r");
$file_contents = fread($file, filesize( $data_file ));
fclose($file);
$lines = explode("\n", $file_contents);
$new_lines = array();
foreach ($lines as $line) {
$data = explode('|', $line);
$ip = $data[0];
$time = $data[1];
***** Trouble Starts Here ******
if (($ip != $visitor_ip) && (($time_now - $time) < $timeout)) {
$new_lines[] = $lines;
}
}
if ($new_lines != "") {
$new_contents = explode(",", $new_lines);
$count = count(new_lines);
print "$new_lines[1]<br>\n";
print "$count<br>\n";
}
else {
print "error";
}
$file = fopen($data_file, "w");
fwrite($file, "$file_contents"); // Want to be able to use the filtered $new_contents array here
fwrite($file, "$visitor_ip|$time_now\n");
fclose($file);
exit;