Hi, Can anyone help in writing preg_match for the line 2007-10-08 00:00:05 W3SVC31713 216-55-183-237 216.55.183.237 GET /jwalker.swf - 80 - 98.194.15.17 Plz help me regrading this.. Cheers, app_1
I think you're better off using sscanf() here. $string = '2007-10-08 00:00:05 W3SVC31713 216-55-183-237 216.55.183.237 GET /jwalker.swf - 80 - 98.194.15.17'; $data = sscanf($string, '%s %s %s %s %s GET %s - %d - %s'); print_r($data); PHP: Edit: Or maybe even exploding the string on the spaces using explode()
HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.7)+Gecko/20070914+Firefox/2.0.0.7 how to parse this ??? the line is 2007-10-08 00:00:05 W3SVC31713 216-55-183-237 216.55.183.237 GET /jwalker.swf - 80 - 98.194.15.17 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.7)+Gecko/20070914+Firefox/2.0.0.7
hey,i got that one..thanks.. but next field i have like www.magicaltransformation.com,but its taking as arr[2] = www.magictr rest of charater not getting. Any idea ???
ok.. line is 2007-10-08 00:00:05 W3SVC31713 216-55-183-237 216.55.183.237 GET /jwalker.swf - 80 - 98.194.15.17 HTTP/1.1 Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.7)+Gecko/20070914+Firefox/2.0.0.7 - http://www.ravenwilliams.com/index.php?option=com_content&task=view&id=116&Itemid=105 www.magicaltransformations.com and output i am getting is parser started at 1192442071.88Array ( [0] => 2007-10-08 [1] => 00:00:05 [2] => W3SVC31713 [3] => 216-55-183-237 [4] => 216.55.183.237 [5] => GET [6] => /jwalker.swf [7] => 80 [8] => 98.194.15.17 [9] => HTTP/1.1 [10] => Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.7)+Gecko/20070914+Firefox/2.0.0.7 [11] => http://www.ravenwilliams.com/index.php?option=com_content&task=view&id=116&Itemid=105 [12] => www.magicaltr ) not getting full data... y ??
i used ssanf,but that last data www.magaicaltranformation.com not getting fully getting only www.magtran is there any max limit to array ????
I tested it and it's working for me. Did you try the last line of code I gave you? I get this output. Array ( [0] => 2007-10-08 [1] => 00:00:05 [2] => W3SVC31713 [3] => 216-55-183-237 [4] => 216.55.183.237 [5] => /jwalker.swf [6] => 80 [7] => 98.194.15.17 [8] => HTTP/1.1 [9] => Mozilla/5.0+(Windows;+U;+Windows+NT+5.1;+en-US;+rv:1.8.1.7)+Gecko/20070914+Firefox/2.0.0.7 [10] => http://www.ravenwilliams.com/index.php?option=com_content&task=view&id=116&Itemid=105 [11] => www.magicaltransformations.com ) Code (markup):