Created
September 15, 2009 11:55
-
-
Save TheNicholasNick/187241 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function parse2(&$handle, &$game_array){ | |
global $total_games; // I dislike this more and more | |
while(!feof($handle)){ | |
$text = fgets($handle); | |
// do we want to deal with this line of text? | |
if(preg_match("/creating game|shutting down|started loading|Game.*is over/", $text)){ | |
// yes we do, get the timestamp | |
$date = substr($text, 1, 24); | |
// now do something with it | |
switch (true) { | |
case preg_match("/creating game (\[.*\])/", $text, $matches): | |
echo $date . ": " . substr($matches[1], 1, $matches[1].length-1); | |
break; | |
} | |
} | |
} | |
// sample data for reference (as of 15.0) | |
// [Tue Sep 15 19:58:55 2009] [GHOST] creating game [Element TD v4.1b [bot 434]] | |
// [Tue Sep 15 20:02:10 2009] [GAME: Element TD v4.1b [bot 434]] started loading with 3 players | |
// [Tue Sep 15 21:06:23 2009] [QUEUED: West] Game [Element TD v4.1b [bot 434] : SoreGums : 0/3 : 63m] is over. | |
// [Tue Sep 15 21:17:44 2009] [GHOST] shutting down | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment