<?php
$str = '127.0.0.1 - - [08/Dec/2015:13:39:52 +0800] "GET /static/img/demo/av1.jpg?eventCode=pv&pageId=40119E07-6F56-4007-8C95-6F7533F11A86&siteId=1&referrer=http%3A%2F%2Ff.iqiyi.com%2F&url=http%3A%2F%2Fstar.haibao.com%2Farticle%2F2214845.htm&userId=0&unRegUserId=B178F3C8-02A8-428C-B466-265B8A2AD8C0 HTTP/1.1" 200 2110 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"';
//print_r(explode(' ', $str));
$p = '/^(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})\s-\s(.*)\s\[(.*)\]\s"(.*)\"\s(\d{3})\s(\d+)\s"(.*)"\s\"(.*)\"(.*)$/u';
preg_match($p,$str,$a_match);
print_r($a_match);
- Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- Array
(
[0] => 127.0.0.1 - - [08/Dec/2015:13:39:52 +0800] "GET /static/img/demo/av1.jpg?eventCode=pv&pageId=40119E07-6F56-4007-8C95-6F7533F11A86&siteId=1&referrer=http%3A%2F%2Ff.iqiyi.com%2F&url=http%3A%2F%2Fstar.haibao.com%2Farticle%2F2214845.htm&userId=0&unRegUserId=B178F3C8-02A8-428C-B466-265B8A2AD8C0 HTTP/1.1" 200 2110 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"
[1] => 127.0.0.1
[2] => -
[3] => 08/Dec/2015:13:39:52 +0800
[4] => GET /static/img/demo/av1.jpg?eventCode=pv&pageId=40119E07-6F56-4007-8C95-6F7533F11A86&siteId=1&referrer=http%3A%2F%2Ff.iqiyi.com%2F&url=http%3A%2F%2Fstar.haibao.com%2Farticle%2F2214845.htm&userId=0&unRegUserId=B178F3C8-02A8-428C-B466-265B8A2AD8C0 HTTP/1.1
[5] => 200
[6] => 2110
[7] => -
[8] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
[9] =>
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[0] => 127.0.0.1 - - [08/Dec/2015:13:39:52 +0800] "GET /static/img/demo/av1.jpg?eventCode=pv&pageId=40119E07-6F56-4007-8C95-6F7533F11A86&siteId=1&referrer=http%3A%2F%2Ff.iqiyi.com%2F&url=http%3A%2F%2Fstar.haibao.com%2Farticle%2F2214845.htm&userId=0&unRegUserId=B178F3C8-02A8-428C-B466-265B8A2AD8C0 HTTP/1.1" 200 2110 "-" "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36"
[1] => 127.0.0.1
[2] => -
[3] => 08/Dec/2015:13:39:52 +0800
[4] => GET /static/img/demo/av1.jpg?eventCode=pv&pageId=40119E07-6F56-4007-8C95-6F7533F11A86&siteId=1&referrer=http%3A%2F%2Ff.iqiyi.com%2F&url=http%3A%2F%2Fstar.haibao.com%2Farticle%2F2214845.htm&userId=0&unRegUserId=B178F3C8-02A8-428C-B466-265B8A2AD8C0 HTTP/1.1
[5] => 200
[6] => 2110
[7] => -
[8] => Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2490.71 Safari/537.36
[9] =>
)
preferences:
156.69 ms | 404 KiB | 213 Q