I’m just poking around with some log files, and was curious as to how I could parse the data and extract some specific information based on parameters which are determined by my marketing campaign. I suppose I should go to a more specific PHP forum for this, but I thought I’d throw it out here first, just in case anyone had some experience here.
I’m ultimately thinking of creating a plugin which will analyze CUSTOM data which a user can set to any value they like in the admin panel of either WP or BB.
I need to read line by line, and extract certain parts of a line, compare some of those parts with other lines to find similarities. I think an example is best:
88.88.888.88 – – [02/Mar/2007:00:56:38 -0800] “POST /url/of/page/requested/ HTTP/1.1” 304 256 “/url/of/page/referring/” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en) AppleWebKit/418.9.1 (KHTML, like Gecko) Safari/419.3”
This line has a lot of data. All I need is to find out if the url of page requested matches a pre-defined value. Then, I need to find out what the ip address is if it does match the value. I would then need to parse back through the file and pull every line that had a matching ip address.
Hope this explanation is clear. If anyone has any suggestions, or knows of any simple resources to start this happening, that would be extremely helpful.
P.S. I’ve read up a little on fget() and file(), but they’re still a little greek to me. A simple example that might work in my case would be most helpful.
- The topic ‘PHP – Parsing text from logfile’ is closed to new replies.