<?php
$now=time();
$fileName=date("H-i-s",$now).".txt";
$fileWrite=microtime(true);
$nowData=array();
if(!file_exists($fileName)){fclose(fopen($fileName,"w"));}
$fp=fopen($fileName,"r+");
flock($fp,LOCK_EX);
while(($buffer = fgets($fp)) !== false){
$buffer=trim($buffer);
if(!preg_match("{[0-9]+:[0-9-]+}",$buffer)){continue;}
$nowData[]=$buffer;
}
$count=count($nowData);
$nowData[]="{$count}:{$fileWrite}";
ftruncate($fp,0);
fseek($fp,0);
fwrite($fp,implode("\n",$nowData));
fclose($fp);
print("<pre>");var_dump($nowData);print("</pre>");
?>
ツイートシェア