我有一个array
包含多个团队。我希望每支球队都和其他球队一起比赛。
我曾尝试这样做,for loop
但没有任何效果。
数组是这样的。
Array ( [0] => 2 [1] => 3 [2] => 8 [3] => 9 [4] => 11 [5] => 12 )
我想这样做。
[0] - [1]
[0] - [2]
[0] - [3]
[0] - [4]
[0] - [5]
[1] - [2]
[1] - [3]
[1] - [4]
[1] - [5]
[2] - [3]
[2] - [4]
[2] - [5]
[3] - [4]
[3] - [5]
[4] - [5]
我的代码是这样的
function createMatchesStandings($teams,$homeaway,$round)
{
include_once('class_match.php');
if($homeaway == 0)
{
// one way matches
$numberOfMatches = count($teams) - 1;
for($i = 0; $i<=$numberOfMatches;$i++)
{
$match = new Match();
$match->standing = $this->id;
$match->round = $round;
$match->home_team = $teams[$i];
$match->away_team = $teams[$i+1];
$match->week = $i;
$match->date = '0000-00-00';
$match->insert();
}
}elseif($homeaway == 1)
{
// home away matches ($teams * 2) - 2
}
}