Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2.  
  3. $teams = 'Legia,RKS,Arka,Lechia,Górnik,Lech,Warta Działoszyn,Real Madryt,WKS,Raków Częstochowa,Barcelona';
  4. $group = 10; // amount of groups
  5.  
  6. echo $teams;
  7. echo '<br/>';
  8.  
  9. $teams = explode(',', $teams);
  10.  
  11. echo '<pre>';
  12. print_r($teams);
  13. echo '</pre>';
  14.  
  15. $no = count($teams);
  16. echo 'Liczba podanych klubów: '.$no.'<br/>';
  17.  
  18. $tig = ceil($no/$group); // Teams In Group (amount)
  19. echo 'Liczba druzyn w 1 grupie = '.$tig.'<br/>';
  20.  
  21. $groups = array();
  22.  
  23. for($i=0; $i < $group; $i++)
  24. {
  25.     echo 'iteracja '.$i.'<br/>';
  26.  
  27.     $t = $i;
  28.     echo 'grupa nr '.(++$t).'<br/>';
  29.  
  30.     for($j=0+($tig*$i); $j < $tig+($tig*$i); $j++)
  31.     {
  32.         if(empty($teams[$j])) break;
  33.         echo 'itracja j = '.$j.' klub = '.$teams[$j].'<br/>';
  34.         $groups[$t][] = $teams[$j];
  35.     }
  36. }
  37.  
  38. echo '<pre>';
  39. print_r($groups);
  40. echo '</pre>';
  41.  
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement