| 
 Posted by kurtis.jensen on 04/18/06 10:44 
I'm not sure this is what your looking for but here is what I came up 
with: 
 
<?php 
$game[1]= "Game 1"; 
$game[2]= "Game 2"; 
 
$scores[1]['2'] = 19;// Game One Team 2 
$scores[1]['4'] = 25;// Game One Team 4 
 
// This could also be written as: $scores[0] array(2 => 19, 4 => 25); 
 
$scores[2]['2'] = 23;// Game Two Team 2 
$scores[2]['4'] = 25;// Game Two Team 4 
 
// This is a two dimentional array where the primary key is the game 
number 
// and the second keys are the team # and the value is the points. 
 
//####################### 
//      Output 
//####################### 
 
// walk through each game 
foreach ($game as $Key => $Description){ 
	echo "<br/>".$Description.":<br/>"; 
 
	// turn the $scores[GameNumber] from an associated to a numerical 
array 
        // (because we won't always know what the team number is) and 
put 
        // the values into $Score1 and $Score2. 
	list ($Score1,$Score2) = array_values($scores[$Key]); 
 
       // Calculate the difference 
	$Diff = abs($Score1-$Score2); 
 
	// walk through each score for the current game 
	foreach ($scores[$Key] as $team => $points) { 
 
                // show output for each team 
		echo "Team: ".$team.", Points: ".$points.", Difference: 
".$Diff."<br>";	 
		} 
	 
	}  
?> 
----------------------- 
Good Luck!
 
[Back to original message] 
 |