【发布时间】:2012-08-25 13:19:47
【问题描述】:
好的,我之前对此有疑问。
我发现了如何使用基于unix时间的php删除txt文件中的行
这是我当前的代码。
<?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();
?>
该代码的作用是文件中的每个条目在 Unix 中都会有一个时间
所以
它是这样设置的
Content | Unix Time
Content | Unix Time
我想要做的是有一个 PHRASE 或 WORD 代替 unix 时间,这表明该行需要留在那里。
是否有 sn-p 或者这很难吗?
任何帮助将不胜感激。
【问题讨论】:
标签: php unix time code-snippets