Метод № 1
$at = $_SERVER['REMOTE_ADDR'];
$log = file_get_contents("logs.txt");
$log = trim($log); // removes leading/trailing blank lines
$log = explode("\n", $log);
$log[] = $at;
$log = array_unique($log);
$log = implode("\n", $log);
file_put_contents("logs.txt", $log);
Метод № 2
$at = $_SERVER['REMOTE_ADDR'];
$log = file_get_contents("logs.txt");
$temp = explode("\n", $log);
if(in_array($at, $temp) == false) {
file_put_contents("logs.txt", $log . $at . "\n");
}