Ho questo script ke mi crea una tabella in un file html:

codice:
<?
/***************************************************************************
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms available from CloudMods.
 *   Written by Olympus_Hermes and FOPT_Cloudberry
 *
 ***************************************************************************/
// ~~ Array Initializations ~~
$sockets = Array();
$ret_done = Array();
$ret_data = Array();
$parsed_data = Array();

// ~~ Include necessary files ~~
include('functions.php');
include('template_engine.php');
$template = new Template;

// ~~ Obtain the list of players which have to be on the ratings list ~~
$player_file = 'players.txt';
$fp = fopen($player_file, 'r');
$player_list = fread($fp, filesize($player_file));
$players = explode("\n", $player_list);
$num_players = count($players);

// ~~ Open the sockets and prepare them for non-blocking! ~~
$host = 'classic.zone.msn.com';
for( $i = 0; $i < $num_players; $i++ )
{
	$sockets[$i] = fsockopen($host, 80, $errno, $errstr, 30);
	stream_set_blocking($sockets[$i], FALSE);
	$path = '/Profile/RatingsPlayer.asp?Players=2&Teams=&PlayerID=' . trim($players[$i]) . '&TeamID=&pguest=1';
	fputs($sockets[$i],"GET $path HTTP/1.0\r\nHost: $host\r\n\r\n");
}

// ~~ Grab the data from each profile simeltaneous, using the prepared sockets! ~~
$done = false;
while( !$done )
{
	for( $i = 0; $i < $num_players; $i++ ) 
	{
   		if( !feof($sockets[$i]) ) 
		{
    		if( $ret_data[$i] )
			{
     			$ret_data[$i] .= fgets($sockets[$i], 8192);
    		}
			else
			{
     			$ret_data[$i] = fgets($sockets[$i], 8192);
			}
   		}
		else
		{
			$ret_done[$i] = 1;
		}
  	}
 	$done = (array_sum($ret_done) == $num_players);
}

// ~~ Parse the obtained data ~~
$total_rat=0; 
$unrated=0; 
for( $i = 0; $i < count($ret_data); $i++ ) 
{ 
   $ret_data[$i]= substr($ret_data[$i], 8000); 
   $parsed_data[$i] = parse_profile(&$ret_data[$i]); 
   $total_rat+=$parsed_data[$i]['rating']; 
   if ($parsed_data[$i]['rating']=='-') $unrated+=1; 
}

// ~~ Sort the player attributes on rating ~~
usort( $parsed_data, "sorter" ); 

// ~~ Assign the template file ~~
$template->set_filenames(array(
	'template' => 'template.htm' )
);

// ~~ Put the data in the template blocks ~~
for( $i = 0; $i < count($parsed_data); $i++ )
{
	if( !empty($parsed_data[$i]['nick']) )
	{
		$template->assign_block_vars('row', array(
			'NICK' => '' . $parsed_data[$i]['nick'] . '',
			'RATING' => $parsed_data[$i]['rating'],
			'GAMES' => $parsed_data[$i]['games'],
			'WINS' => $parsed_data[$i]['wins'],
			'LOSSES' => $parsed_data[$i]['losses'],
			'TIES' => $parsed_data[$i]['ties'],
			'INCOMP' => $parsed_data[$i]['incomp'],
			'STREAK' => $parsed_data[$i]['streak'],
			'CLASS' => give_class(),
			'WINPERCENT' => $parsed_data[$i]['winpercent'] )
		);
	}
}
$template->assign_vars(array( 
   'AVERAGE' => round($total_rat/($num_players-$unrated))) 
);
// ~~ Output the data to the template ~~
$template->pparse('template');
?>
.....continua