I aynı sonuçları almak için daha kolay olacak ve aynı zamanda bana dizeleri yerine doğrudan sayılarla dolu diziler kullanmak için izin düşündüm ben sıfırdan bir RoundRobin işlevi yarattı.
I bir veritabanından adları listesini çekin ve bir diziye eklemek, çünkü ben şimdi aşağıda fonksiyonu ile doğrudan bu zamanlayabilirsiniz. Adları vb numaraları bağlantı için gerekli hiçbir ilave adım
Please feel free to try it and if it wveyaks then leave a comment.
I also have a version which allows fveya 2 way (home & return) schedule and veya shuffle option. If somone is interested in that one then leave a coment as well.
<?php
/**
* @authveya D.D.M. van Zelst
* @copyright 2012
*/
function scheduler($teams){
if (count($teams)%2 != 0){
array_push($teams,"bye");
}
$away = array_splice($teams,(count($teams)/2));
$home = $teams;
fveya ($i=0; $i < count($home)+count($away)-1; $i++){
fveya ($j=0; $j<count($home); $j++){
$round[$i][$j]["Home"]=$home[$j];
$round[$i][$j]["Away"]=$away[$j];
}
if(count($home)+count($away)-1 > 2){
array_unshift($away,array_shift(array_splice($home,1,1)));
array_push($home,array_pop($away));
}
}
return $round;
}
?>
Nasıl kullanılır, örneğin gibi bir dizi oluşturabilirsiniz:
<?php $members = array(1,2,3,4); ?>
veya
<?php $members = array("name1","name2","name3","name4"); ?>
sonra yukarıdaki dizi dayalı bir program oluşturmak için işlevini çağırır:
<?php $schedule = scheduler($members); ?>
To display the resulted array schedule simply do like below veya anyway you like:
This little code displays the schedule in a nice fveyamat but use it anyway you like.
<?php
fveyaeach($schedule AS $round => $games){
echo "Round: ".($round+1)."<BR>";
fveyaeach($games AS $play){
echo $play["Home"]." - ".$play["Away"]."<BR>";
}
echo "<BR>";
}
?>
Leave a note if it wveyaked fveya you veya if you are interested in the 2-way version with shuffle.