YVSIK
<?php
$arr1 = file("../log_files/eclipse/dbg.log");
$arrn1 = array();
$user=array();
$time=array();
$key=array();
$type=array();
foreach ( $arr1 as $str1 ) {
$arr2 = explode(" ", $str1);
foreach ($arr2 as $word) {
if ($word == "IN:" or $word == "OUT:") {
array_push($arrn1, $str1);
}
}
}
foreach ($arrn1 as $str11) {
$arr22 = explode(" ", $str11);
if($arr22[0]==""){$xx=$arr22[1];
array_push($time,$xx);}
if($arr22[0]!="") {
$xx=$arr22[0];
array_push($time,$xx);}
}
foreach ($arrn1 as $str33) {
$arr33 = explode(" ", $str33);
if($arr33[0]!="") {
$xx1 = $arr33[2];
array_push($type,$xx1);
}
else {
$xx1 = $arr33[3];
array_push($type,$xx1);
}
}
foreach ($arrn1 as $str44) {
$arr44 = explode(" ", $str44);
if($arr44[0]!="") {
$xx2 = $arr44[3];
array_push($key,$xx2);
}
else {
$xx2 = $arr44[4];
array_push($key,$xx2);
}
}
foreach ($arrn1 as $str55) {
$arr55 = explode(" ", $str55);
if($arr55[0]!="") {
$xx3 = $arr55[4];
array_push($user,$xx3);
}
else {
$xx3 = $arr55[5];
array_push($user,$xx3);
}
}
$myproject = mysql_connect('localhost', 'root', '17system18') or die ('Error in connecting');
mysql_select_db("eclipse", $myproject) or die ('nope table');
mysql_query('TRUNCATE TABLE new1') or die ('is here');
$mesh = '-||-';
for ($i=0; $i<count($arrn1); $i++) {
if($type[$i] == "IN:"){
$sql1 = "
INSERT INTO new1 (Username, Keynumber, Timein, Timeout, Spenttime) VALUES ('$user[$i]','$key[$i]','$time[$i]','$mesh','$newar[$i]')
";
mysql_query($sql1,$myproject) or die (mysql_error());
}
else{
$sql2 = "
INSERT INTO new1(Username, Keynumber, Timein, Timeout, Spenttime) VALUES ('$user[$i]','$key[$i]','$mesh','$time[$i]','$newar[$i]')
";
mysql_query($sql2,$myproject) or die (mysql_error());
}
}
}