我想从旧日志文件中删除所有行并保留底部的新 50 行。
我该怎么做这样的事情,如果可能的话,我们可以改变这些线条的方向,
normal input
111111
2222222
3333333
44444444
5555555
output like
555555
4444444
3333333
22222
111111
仅查看顶部和 50 或 100 行的新鲜日志。
如何加入这个?
// set source file name and path
$source = "toi200686.txt";
// read raw text as array
$raw = file($source) or die("Cannot read file");
// join remaining data into string
$data = join('', $raw);
// replace special characters with HTML entities
// replace line breaks with <br />
$html = nl2br(htmlspecialchars($data));
它将输出作为 HTML 文件。那么你的代码将如何运行呢?