如何从文本的最后一行开始读取?
解决方案 »
- 数学不好能学php吗
- Cannot modify header information - headers already sent by ?
- 菜鸟之每日一问:php函数定义
- 求助~~~~有关PHP的持续集成~~~~~~~~~
- 在两位数字间加分割符
- How to make IIS5.1 read the new php.ini?
- php的最小倚赖条件是什么?
- 问个简单的问题散分(关于日期的)
- php 菜鸟问题
- Apache/2.4.9 (Win32) PHP/5.5.12 Server at localhost Port 80
- 求教高手PHP截取字符串数量
- Fri Oct 29 16:17:46.356 2010 这是什么时间格式?
if(!file_exists("tx.txt"))return ;
$file=file("tx.txt");
echo "<pre>";
var_dump($file);
foreach($file as $value)
{
$foo=array_pop($file);//将最后一个元素弹出栈。
var_dump($foo);
}
echo "</pre>";
echo '<pre>';
function gettime(){
$nowtime = explode(' ',microtime());
return $nowtime[0]+$nowtime[1];
}
$start = gettime();
$data=file_get_contents('query.log');$dataarray=explode('[idxmain]',$data);
$str='';
foreach($dataarray as $key=>$val){
if($key==0){
$str.=substr($val,strpos($val,'[')+1,28).','; }elseif($key>=1){
$str.=substr($val,0,strpos($val,'[')).',';
$str.=substr($val,strpos($val,'[')+1,28).',';
}
}
$keyword='';
$array=explode(',',$str);
$i=0;
$j=0;
foreach($array as $key=>$val){
if($val!=''){
$keyword.=trim($val);
if($j==$i){
$keyword.=',';
}
$j++;
}
$i++;
}
$wordarray=explode(',',$keyword);
$new_array =array_count_values($wordarray);
print_r($new_array);
echo '</pre>';echo '<br />';
$end = gettime();
$count =$end-$start;
echo ' 用时:'.$count;
?>