Строка:
[27/Apr/2020:19:14:17 +0000] GET https://domain/api/lead/0/43927/0/0 pid:28254 took:0.171s mem:8mb cpu:58.62% status:200 {54.227.122.223|Zapier}
Регулярка:
$regex = '/(^\[(?<datetime>.*)\]) (?P<method>OPTIONS|GET|HEAD|POST|PUT|DELETE|TRACE|CONNECT|PATCH|PROPFIND) (?P<url>.+?\S) (?P<pid>.+?\S) (?P<took>.+?\S) (?P<mem>.+?\S) (?P<cpu>.+?\S) (?P<status>.+?\S+)/';
Результат:
Array
(
[0] => [27/Apr/2020:19:14:17 +0000] GET https://domain/api/lead/0/43927/0/0 pid:28254 took:0.171s mem:8mb cpu:58.62% status:200
[1] => [27/Apr/2020:19:14:17 +0000]
[datetime] => 27/Apr/2020:19:14:17 +0000
[2] => 27/Apr/2020:19:14:17 +0000
[method] => GET
[3] => GET
[url] => https://domain/api/lead/0/43927/0/0
[4] => https://domain/api/lead/0/43927/0/0
[pid] => pid:28254
[5] => pid:28254
[took] => took:0.171s
[6] => took:0.171s
[mem] => mem:8mb
[7] => mem:8mb
[cpu] => cpu:58.62%
[8] => cpu:58.62%
[status] => status:200
[9] => status:200
)
Как в pid, took, mem, cpu, status получить только цифровые значения?
Что бы было к примеру
['pid' => 28254, 'cpu' => 58.62]