PHP+文本数据 如何只保存10条记录

WBOY
Release: 2016-06-23 14:18:49
Original
979 people have browsed it

超过10条自动删除第一条。如何实现。


回复讨论(解决方案)

可以实现。首先读出文件里面的条数,及数据,放入到数组里面,接下来你知道再把你要的数据写进去,不就可以了呀。

$fn = '文本数据文件名';file_put_contents($fn, join('', array_slice(file($fn), -10)));
Copy after login

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template