Thank you all for your replies...let me elaborate on my situation as there might be a better way to solve this...
The log file has data such as (taken right from the log file, player names and uid changed):
[Mon Apr 30 17:11:29 2007] *** Results for Map: Worlds\ReleaseMultiplayer\Office
[Mon Apr 30 17:11:29 2007]
[Mon Apr 30 17:11:29 2007] Player: l33tPlayer (uid: e43A932e4df9115ba34tt3898d64307f)
[Mon Apr 30 17:11:29 2007] Score: 97
[Mon Apr 30 17:11:29 2007] Kills: 22
[Mon Apr 30 17:11:29 2007] Deaths: 10
[Mon Apr 30 17:11:29 2007] Team Kills: 0
[Mon Apr 30 17:11:29 2007] Suicides: 1
[Mon Apr 30 17:11:29 2007] Objective: 0
[Mon Apr 30 17:11:29 2007]
[Mon Apr 30 17:11:29 2007] Player: TheKing (uid: 6ee1b98804d39a99930d7c1ba38ccc2l)
[Mon Apr 30 17:11:29 2007] Score: 17
[Mon Apr 30 17:11:29 2007] Kills: 7
[Mon Apr 30 17:11:29 2007] Deaths: 18
[Mon Apr 30 17:11:29 2007] Team Kills: 0
[Mon Apr 30 17:11:29 2007] Suicides: 0
[Mon Apr 30 17:11:29 2007] Objective: 0
Currently, I have a custom class that reads the file in reverse, parsing each line and checking them against an array of regular expressions. Here is that array of regexs:
Regex array
$patterns = array(
array('Player', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Player:\s+(.*)\s+\(uid:\s+(?:.*)\)$/'),
array('UID', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Player:\s+(?:.*)\(uid:\s+(.*)\)$/'),
array('Score', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Score:(.*)(?:.*)?$/'),
array('Kills', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Kills:(.*)(?:.*)?$/'),
array('Deaths', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Deaths:(.*)(?:.*)?$/'),
array('Team Kills', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Team Kills:(.*)(?:.*)?$/'),
array('Suicides', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Suicides:(.*)(?:.*)?$/'),
array('Objective', '/^\[(?:Mon|Tue|Wed|Thu|Fri|Sat|Sun)\s+(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+(?:[0-9]{2})\s+(?:[0-9]{2}):(?:[0-9]{2}):(?:[0-9]{2})\s+20(?:[0-9]{2})\]\s+Objective:(.*)(?:.*)?$/')
);
Now, the first item in each array (e.g. Player, Score, etc) is currently how we name each key of the (new) array we put the results in. It will make a little bit more sense in a minute...I hope.
Here is the routine that parses the file and currently creates my flattened array...the part that I think really needs help (root of the problem):
private function parseFile(){
// until SOF or our index pointer is reached, we read from the bottom up of the file
$tt = 0;
while(!$this->reader->sof()){
$line = $this->reader->GetLine();
for($i = 0; $i < count($this->checks); $i++){
if(preg_match($this->checks[$i][1], $line, $matches)){
$this->data[$tt][$this->checks[$i][0]] = $matches[1];
$tt++;
}
}
}
// Since we read the file in reverse, let's flip the data right side up in the array
$this->data = array_reverse($this->data);
}
Notes: sof() returns the pointer to the start of the file (e.g. 0 [zero]). $this->checks is the array of checks (regexs) passed to this class (what we are trying to find in the file).
Now, if there was a nice and easy way to just create the array as needed right here...that would save a lot of work.
This is the format I need (or at least it would be easier to work with for a lot of things):
Array
(
[0] => Array
(
[0] => l33tPlayer
[1] => 97
[2] => 22
[3] => 10
[4] => 0
[5] => 1
[6] => 0
)
[1] => Array
(
[0] => TheKing
[1] => 17
[2] => 7
[3] => 18
[4] => 0
[5] => 0
[6] => 0
)
)
After I have the array, I basically create "player" objects that calculate and update the DB (I won't get into that here...I need to clean that code up too much and do some refactoring first...).
Thank you all so much again. I hope this post here helps.