Php Script to distrubate person working in a week : I made this Script to distrubate person working in a week but No one can work more than one time in a day and  also must work 6 days/week  But steel some problems cause some people work just 4 days some work more ...  I tried doing it this way :


    <?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";
    ?>