关于正则匹配字符串之间的字符

  header("content-type:text/html;charset=utf-8");
  session_start();
  date_default_timezone_set('PRC');
  ini_set('memory_limit','2048M');
  include ("mysql.php");
  $t=new db('test');
  $pattern='/SET timestamp=\d{10};(.*?)# Time: \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}.\d{6}Z/s';
  $dir = "log";
  $a = scandir($dir,1);
  $length=count($a)-2;
  for($i=0;$i<$length;$i++){
    $cont=file_get_contents('log/'.$a[$i]);
    preg_match_all($pattern, $cont, $matches);
    foreach ($matches[1] as $key => $value) {
        $sql="INSERT INTO sql_item VALUES (NULL , '{$value}')";
        $t->query($sql);
    }
  }
内容:SET timestamp=1505808023;
select id,cover,tel,tel2,title,areaid,areaid_hy,posttime,isyp,price,begindate,enddate from infos where isshow=1 and isyp=0 and bigsortid=1 and sortid=42 and areaid=1 order by ordertime desc limit 180,20;
# Time: 2017-09-19T08:00:24.349152Z
# User@Host: root[root] @ localhost []  Id:    10
# Query_time: 0.999307  Lock_time: 0.000060 Rows_sent: 1  Rows_examined: 282906
SET timestamp=1505808024;
SELECT count(infos.id) as num
FROM (`infos`)
WHERE `isshow` =  1
LIMIT 1;
# Time: 2017-09-19T08:00:24.414706Z
# User@Host: root[root] @ localhost []  Id:    17
# Query_time: 0.808071  Lock_time: 0.000714 Rows_sent: 6  Rows_examined: 238787
use vanpeopl_info;
SET timestamp=1505808024;

你可能感兴趣的:(关于正则匹配字符串之间的字符)