<? php dynamic code for football

I want the winner to be printed with the number 1 and the loser to be printed with the number 0, that is, when 2 teams out of 4 teams are selected, it will appear in the output as follows. For example, these 4 teams, 2 teams, have the following 6 modes
A = B

1 0 0 Team 1&
1 0 0 Team 2&
1 1 1 Team 3&
1 1 1 Team 4&
A = B

1 0 0 Team 1&
0 1 1 Team 2&
1 0 0 Team 3&
1 1 1 Team 4&
A = B

1 0 0 Team 1&
0 1 1 Team 2&
0 1 1 Team 3&
1 0 0 Team 4&
A = B

0 1 1 Team 1&
1 0 0 Team 2&
1 0 0 Team 3&
1 1 1 Team 4&
A = B

0 1 1 Team 1&
1 0 0 Team 2&
0 1 1 Team 3&
1 0 0 Team 4&
A = B

0 1 1 Team 1&
0 1 1 Team 2&
1 0 0 Team 3&
1 0 0 Team 4&

Or 7 teams, 3 teams have 35 modes. I want to give 2 or 3 numbers and receive them in the output mode. I hope I have stated correctly.