【发布时间】:2016-12-09 18:54:02
【问题描述】:
我制作了这个脚本来分配一周工作的人,但没有人一天可以工作超过一次,而且必须每周工作 6 天,但仍然有一些问题导致有些人只工作 4 天,有些人多工作。 问题:如何让人们每周工作 6 天? ...我试过这样做:
<?php
$input = array("Mohamed ET Sidi", "Ahmed ET ibrahim", "senoud","Hamed Et abdou");
$rand_keys = array_rand($input, 4);
?>
<table border=1>
<tr>
<th> Samedi </th>
<th> Dimanche </th>
<th> Lundi </th>
<th> Mardi </th>
<th> Merecredi </th>
<th> Jeudi </th>
<th> Vendredi </th>
</tr>
<tr>
<?php
$counter_MS=0;
$counter_AI=0;
$counter_HA=0;
$last_shift = $input[2];
for($i=0;$i<7;$i++){
echo "<td>\n";
shuffle($input);
// controle no one Continu working
while ($input[0] == $last_shift) {
shuffle($input);
}
// no one work 7 days a week
while ($counter_MS == 6 && $input[0]="Mohamed ET Sidi" || $counter_MS == 6 && $input[1]="Mohamed ET Sidi" || $counter_MS == 6 && $input[2]="Mohamed ET Sidi") {
shuffle($input);
}
while ($counter_AI == 6 && $input[0]="Ahmed ET ibrahim" || $counter_MS == 6 && $input[1]="Ahmed ET ibrahim" || $counter_MS == 6 && $input[2]="Ahmed ET ibrahim") {
shuffle($input);
}
while ($counter_HA == 6 && $input[0]="Hamed Et abdou" || $counter_MS == 6 && $input[1]="Hamed Et abdou" || $counter_MS == 6 && $input[2]="Hamed Et abdou") {
shuffle($input);
}
if( $input[0] =="Mohamed ET Sidi" || $input[1]=="Mohamed ET Sidi" || $input[2]=="Mohamed ET Sidi")
$counter_MS++;
if( $input[0] =="Ahmed ET ibrahim" || $input[1]=="Ahmed ET ibrahim" || $input[2]=="Ahmed ET ibrahim")
$counter_AI++;
if( $input[0] =="Hamed Et abdou" || $input[1]=="Hamed Et abdou" || $input[2]=="Hamed Et abdou")
$counter_HA++;
echo $input[0] ." 7H-15H\n" ;
echo $input[1] ." 15H-23H\n" ;
echo $input[2] ." 23H-7H\n" ;
$last_shift = $input[2];
echo "</td>\n";
}
echo "Mohamed Et Sidi Worked =".$counter_MS." days";
echo "Ahmed ET ibrahim =".$counter_AI." days";
echo "Hamed Et abdou =".$counter_HA." days";
?>
【问题讨论】:
-
你有什么问题?
-
让人们每周工作 6 天
-
´这是一个声明,而不是一个问题:P
-
hhhh 好的,在它之前添加“如何”
-
仍然不是一个正确的问题
标签: php html-table