Heya, hinksta.
The 'problem' with the third print_r() is that there is no intersection between the two tables. PHP has no way of associating the values in the first array with the values in the second array.
Since you already have the team data, you don't need the first array. And since you need to know how many 'win points' you have per team, you'll want to incorporate the team IDs into your second array as the keys.
So for example, using this data:
Team 5 vs. Team 8: Team 5 wins.
Team 3 vs. Team 12: Team 12 wins.
Team 5 vs. Team 7: Tie
Team 8 vs. Team 12: Team 8 wins.
The goal is to end up with one array that looks like this:
-
array(
-
5 => 4, // One win and one tie for team 5
-
8 => 3, // One win for team 8
-
3 => 0, // No wins for team 3
-
12 => 3, // One win for team 12
-
7 => 1 // One tie for team 7
-
);
-
Then, using arsort(), you will end up with this:
-
array(
-
5 => 4,
-
12 => 3,
-
8 => 3,
-
7 => 1,
-
3 => 0
-
);
-
In this case, you now know to display team 5 first, then team 12, then team 8, and so on.