Удалить строку нет совпадения с текущей датой сервера с PHP
Hello everyone! Content of the text file (test.txt): 115.5.108.249 2015-03-01 118.110.6.87 2018-01-03 36.120.105.13 2018-04-06 I'm familiar with the following: <?php $fname = "test.txt"; $date = date("Y-m-d"); foreach($lines as $line) if(!strstr($line, $date)) $out .= $line; $f = fopen($fname, "w"); fwrite($f, $out); fclose($f); ?> This command will only delete the line that contains the current server history and date ($date). I want this command to run in reverse. Line cleaner whose history (date) is old and no match with current server date (The server where PHP runs). I hope you understand what I mean. Thanks.
Что я уже пробовал:
<?php
$имени = "test.txt";
$date = дата("Y-m-d");
по каждому элементу($строки как $строка) если(!strstr($строка, $дата)) долл .= $линия;
$f = fopen($fname, "w");
fwrite($f, $out);
fclose($f);
?>