數組如下:
Array (
[0] => 00:01:24| /api/get.html?act=GetUserOrderList&F=android&V=1.8.0&key=1445961683170&sign=061cffe2b3ee&user_id=709&o_type=1&page=1&size=100
[1] => 00:01:24| /api/get.html?act=GetUserOrderList&F=android&V=1.8.0&key=1445961683158&sign=10dda7993ac0&user_id=709&o_type=1&page=1&size=100
[2] => 11:13:06| /api/geta.html?order_by_id=&act=GetGoodslist&V=1.2.0&page=1&sign=a4519e9950d2&F=ios&key=14460019873701468300&type_id=&g_mark=
);
function InsertLog()
{
foreach($user as $r)
{
//調用數據處理方法
$key=$this->get_arraykey($r);
var_dump($key);
}
}
/**
* @desc 數據處理
* @author 張昀
* @return void
*/
function get_arraykey($data)
{
$str=explode("|",$data);
$strkey=explode("?",$str[1]);
foreach(explode("&",$strkey[1]) as $v) {
$key=explode("=",$v);
if($key[0]=="act") {
$get_key["act"]=$key[1];
}
if($key[0]=="F") {
$get_key["F"]=$key[1];
}
if($key[0]=="V") {
$get_key["V"]=$key[1];
}
if($key[0]=="user_id") {
$get_key["user_id"]=$key[1];
}
}
//輸出數據及格式
return array (
'time' => $str[0] ,
'strkey' => trim($strkey[0]) ,
'act' => "act=".$get_key["act"] ,
'f'=> $get_key["F"],
'v'=> $get_key["V"],
'user_id'=> $get_key["user_id"]
);
}