I got a custom log, roughly 29MBs of user’s data, including user agent. I want to parse through it (essentially just search) and find how many occurances of say, “Firefox” or “MSIE” appear in it, like a mini log parser.
This is where I am stumped.. What I was getting at is explode()ing newlines, and iterate through the array, use:
if stripos($line, 'Firefox') $ff++;"
or something stupid but I realize that would take up a lot of memory/use a lot of functions.
What would be a good way to list number of occurances?
You’ll want to read the file line by line to avoid using up memory with lots of data.
Also depending on the format of your file (which wasn’t supplied), you might want to use regex or a more refined method to count occurences, eg: