Home > php教程 > php手册 > body text

php去掉文件前几行的方法

WBOY
Release: 2016-06-06 19:50:05
Original
1292 people have browsed it

这篇文章主要介绍了php去掉文件前几行的方法,以去除lrc文件前几行为例分析了php操作文件的相关技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了php去掉文件前几行的方法。分享给大家供大家参考。具体如下:

比如去掉lrc文件中开头几行:

[ti:]
[ar:]
[al:]
[by:cww.99Lrc.net]
[00:00.59]dasfdasfasdf
[00:30.18]dafadsf

php实现代码如下:

isDot()) continue; if($fileInfo->getExtension()=="lrc"){ $handle = fopen($fileInfo->getFilename(), 'rw'); $line_num=0; while(!feof($handle)){ $str=fgets($handle, 1024); if(strstr($str, "www.99Lrc.net")){ ob_start(); fpassthru($handle); //fclose($handle); file_put_contents($fileInfo->getFilename(),ob_get_clean()); printf('done'); break; } $line_num++; } fclose($handle); echo $fileInfo->getFilename() . PHP_EOL; } }

希望本文所述对大家的php程序设计有所帮助。

Related labels:
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!