This article mainly introduces the related skills of php file operation. Interested friends can refer to it. I hope it will be helpful to everyone.
The details are as follows:
For example, remove the first few lines in the lrc file:
[ti:]
[ar:]
[al:]
[by:cww.99Lrc.net]
[00:00.59]dasfdasfasdf
[00:30.18]dafadsf
php implementation code is as follows:
<?php foreach (new DirectoryIterator('./') as $fileInfo) { if($fileInfo->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; } }
Summary : The above is the entire content of this article, I hope it will be helpful to everyone's study.
Related recommendations:
php three recursive function implementation methods
php uses the MagickWand module to operate image additions Watermark method
PHP simulates the method of response class in asp
The above is the detailed content of Tips on operating files in php. For more information, please follow other related articles on the PHP Chinese website!