Home >Backend Development >PHP Tutorial >Get the last line of text

Get the last line of text

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:49:021166browse
  1. $rs = 'README.md';
  2. $fp = fopen($rs, 'r');
  3. fseek($fp,-1,SEEK_END);
  4. $s = '';
  5. while(($c = fgetc($fp)) !== false)
  6. {
  7. if($c == "n" && $s) break;
  8. $s = $c . $s;
  9. fseek($fp, -2, SEEK_CUR);
  10. }
  11. fclose($fp);
  12. echo $s;
  13. exit;
复制代码


Statement:
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