. */ //this function provides the info extracted from a gamestat.txt function readgamestat($i) { //this array contains the info that will be returned $info = array( 'num_players' => trim(str_replace('Players: ','',$i[1])), 'map' => trim(str_replace('Map: ','',$i[2])), 'mode'=> trim(str_replace('Gamemode: ','',$i[3])), 'timeleft' => trim(str_replace('Timeleft: ','',$i[4])) ); //support for the teambased gamemodes if ($info['mode'] == 'Capture the Flag' || $info['mode'] == 'Infiltration' || $info['mode'] == 'Teammatch') { $info['teams']['alpha'] = trim(str_replace('Team 1: ','',$i[5])); $info['teams']['bravo'] = trim(str_replace('Team 2: ','',$i[6])); $info['teams']['charlie'] = trim(str_replace('Team 3: ','',$i[7])); $info['teams']['delta'] = trim(str_replace('Team 4: ','',$i[8])); $players_line = 10; } else $players_line = 6; //get the player info a string for ($l = $players_line; $line = $i[$l] ,$l < count($i); $l++) $pla .= $line; //explode then chunk that string $players_info = array_chunk(explode("\n",$pla), 5); //kill the last element since its empty array_pop($players_info); //add each player to the new array foreach($players_info as $p) { $info['players'][] = array( 'name' => $p[0], 'kills' => $p[1], 'deaths' => $p[2], 'team' => $p[3], 'ping' => $p[4], ); } //return the info return $info; } $file = file('gamestat.txt'); $info = readgamestat($file); echo ' '; if (!empty($info['teams'])) { if ($info['mode'] == 'Infiltration' || $info['mode'] == 'Capture the Flag') echo ' '; else foreach($info['teams'] as $t => $s) echo ' '; } echo '
JRGP\'s Sexy DM
Players '.$info['num_players'].'
Map '.$info['map'].'
Gamemode '.$info['mode'].'
Time Left '.$info['timeleft'].'
Alpha Score '.$info['teams']['alpha'].'
Bravo Score '.$info['teams']['bravo'].'
'.$t.' Score '.$s.'
Who? '; if (empty($info['players'])) echo 'no one'; else foreach($info['players'] as $p) echo '' . $p['name'] . '
'; echo'
'; ?>