Created
November 24, 2017 16:59
-
-
Save wakasann/2ce2aa0d5b260f9f2e985a94e3853737 to your computer and use it in GitHub Desktop.
phpreadonefileeachline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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