Ok, Ive had a question on this before.
I found out how to delete lines in a txt file using php based on unix time
this is my current code.
<?php
$output = array();
$lines = file('file.txt');
$now = time();
foreach ($lines as $line) {
list($content, $time) = explode("|", $line);
if ($time > $now) {
$output[] = $line;
}
}
$outstring = implode($output);
file_put_contents("file.txt", $outstring);
print time();
?>
What that code does is every entry in the file will have a time next to it in Unix
So
Its set up like this
Content | Unix Time
Content | Unix Time
What I Want to do is Have a PHRASE or WORD In replace of the unix time, that indicates that line needs to stay there.
Is there a snippet or would this be hard?
Any Help would be appreciated.
Adding
at the top and replacing the
foreachloop with:would convert
To
You can define the string to keep as whatever you like by changing the value given to
$keepStr