Skip to content

Instantly share code, notes, and snippets.

@huanle0610
Created October 7, 2015 12:52
Show Gist options
  • Save huanle0610/1e340469848f5f5b72f4 to your computer and use it in GitHub Desktop.
Save huanle0610/1e340469848f5f5b72f4 to your computer and use it in GitHub Desktop.
format after parse the nginx log
<?php
$str = file_get_contents('C:\Users\huanle0610.HL-PC\Desktop\hk.json');
$arr = json_decode($str, 1);
var_dump($arr['items'][0]);
$list =array();
foreach($arr['items'] as $row)
{
$list[] = sprintf('%s %s %s', $row['method'], $row['url'], $row['protocol']);
}
$list = array_unique($list);
var_dump($list[100]);
foreach($list as $row)
{
list($method, $url, $protocol) = explode(' ', $row);
$list_all[] = array(
'method' => $method,
'url' => $url,
'protocol' => $protocol
);
}
$list = $list_all;
$urls['totalCount'] = count($list);
$urls['items'] = $list;
//var_dump($urls);
file_put_contents('hk2.json', json_encode($urls));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment