logging - Read data from text file with php and create database -


i have text file, huge 1 contains information's need insert database.

here 1 of rows of text file:

 77.242.22.86 - - [10/jul/2013:14:07:26 +0200] "get /web/img/theimage.jpg http/1.1" 304 - "http://www.mywebiste.com/web/"  "mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml,  gecko) chrome/27.0.1453.116 safari/537.36 alexatoolbar/alxg-3.1" 

i using php functions like:

$myfile = "testfile.txt"; $fh = fopen($myfile, 'r'); 

this read text file, said, need data , insert database, here example how need row spli:

 77.242.22.86  [10/jul/2013:14:07:26 +0200]     /web/img/theimage.jpg   http/1.1  304  http://www.mywebiste.com/web/   mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml,  gecko) chrome/27.0.1453.116 safari/537.36 alexatoolbar/alxg-3.1 

please me resolve problem. thank you.

 $test ='77.242.22.86 - - [10/jul/2013:14:07:26 +0200]  "get /web/img/theimage.jpg http/1.1" 304 - "http://www.mywebiste.com/web/"  "mozilla/5.0 (windows nt 6.2; wow64) applewebkit/537.36 (khtml,  gecko) chrome/27.0.1453.116 safari/537.36 alexatoolbar/alxg-3.1"';      function tokenizer($test) {  $test = trim(strtolower($test));  $res=  str_replace(",","",$test);  $res=  str_replace("-","",$res);  $res=  str_replace(' "',"",$res);  $result=  explode(" ", $res);  ($i = 0; $i < count($result); $i++) {  $result[$i] = trim($result[$i]);  echo $result[$i]; ?>   <hr/> <?php   }  return $result; // contains single words  } 

Comments