-
Notifications
You must be signed in to change notification settings - Fork 0
/
grp.php
76 lines (56 loc) · 769 Bytes
/
grp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php
$hr=array('A','B','C','D','E','F','G','H','I');
$lr=array('J','K','L','M','N','O','P','Q');
$ar=array('R','S','T','U','V','W','X','Y','Z');
$hrl=count($hr);
$lrl=count($lr);
$arl=count($ar);
$ts= $hrl+$lrl+$arl;
echo 'Total no. of students = ' . $ts;
$ng=round($ts/7);
echo 'Total no. of groups = ' . $ng;
$gm=array();
$rptr=0;
$r=0;
$c=0;
$ngc=$ng;
while($hrl>0){
if($r < $ngc){
$gm[$r][$c]=$hr[$rptr];
$rptr++;
$r++;
$hrl--;
}
else {
$r=0;
$c++;
}
}
$rptr=0;
while($arl>0){
if($r < $ngc){
$gm[$r][$c]=$ar[$rptr];
$rptr++;
$r++;
$arl--;
}
else {
$r=0;
$c++;
}
}
$rptr=0;
while($lrl>0){
if($r < $ngc){
$gm[$r][$c]=$lr[$rptr];
$rptr++;
$r++;
$lrl--;
}
else {
$r=0;
$c++;
}
}
print_r($gm);
?>