<pre lang='php'>
function combin($CombinList){
$CombineCount = 1;
foreach($CombinList as $Key => $Value){
$CombineCount *= count($Value);
}
$RepeatTime = $CombineCount;
foreach($CombinList as $ClassNo => $StudentList){
$RepeatTime = $RepeatTime/count($StudentList);
$StartPosition = 1;
foreach($StudentList as $Student){
$TempStartPosition = $StartPosition;
$SpaceCount = $CombineCount/count($StudentList)/$RepeatTime;
echo $SpaceCount.'<br/>';
for($J = 1; $J <= $SpaceCount; $J ++){
for($I = 0; $I < $RepeatTime; $I ++){
$Result[$TempStartPosition + $I][$ClassNo] = $Student;
}
$TempStartPosition += $RepeatTime * count($StudentList);
}
$StartPosition += $RepeatTime;
}
}
return $Result;
}
</pre>