Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@wakasann
Created November 24, 2017 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wakasann/2ce2aa0d5b260f9f2e985a94e3853737 to your computer and use it in GitHub Desktop.
Save wakasann/2ce2aa0d5b260f9f2e985a94e3853737 to your computer and use it in GitHub Desktop.
phpreadonefileeachline
<?php
//read log file each line,i only need get url line,so use strpos method
// my log file text is:
// /test/index.php //url
// 2017-11-19 00:00;:00 // datetime
// <pre>Array // echo "<pre>";print_r(array());echo "</pre>";
// (
// )
// </pre>
$path = "./log2/2017_07_03_12_00request.log";
$handle = fopen($path,'r');
//echo fread($handle,filesize($path));
while(!feof($handle)){
$buffer = fgets($handle);
$content = trim($buffer);
if(strpos($content,'/test') === 0){
echo $content."<br/>";
}
}
fclose($handle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment