mardi 24 novembre 2020

why is the value of my output doubling? how can I store the exact values for each file at the end without doubling?

 foreach ($fileContent as $stData){
        while(!feof($f)) {
            $stData = explode(',', trim(fgets($f, 1024)));
            
           if ((filter_var($stData[1], FILTER_VALIDATE_INT, array("options" => array("min_range"=>0, "max_range"=>100))))&& preg_match('/^\d{8}$/', $stData[0])){
               echo $stData[0]. " : " . $stData[1]. "</br>";
               $goodStudents[] = $stData;
                    
               
           }elseif ((filter_var($stData[1], FILTER_VALIDATE_INT, array("options" => array("min_range"=>0, "max_range"=>100)))==false)&& preg_match('/^\d{8}$/', $stData[0])) {
               echo $stData[0]. " : " . $stData[1]. " : Incorrect mark : not included </br>";
               
           } else {
               echo $stData[0]. " : " .$stData[1]. " : Incorrect ID : not included </br>";
               
           }
           
        }//while
            
        
                                     
     };//foreach student & mark

     print_r (count($goodStudents));
     

OUTPUT:

12345678 : 56

3456782 : 67 : Incorrect ID : not included

12324654 : 98

23476901 : 53

12563792 : 49

74537299 : 7

99834511 : 50

77625489 : 56

55274559 : 63

22009643 : 711 : Incorrect mark : not included

8 --- THE ARRAYS STORED

12345678 : 56

34567822 : 67

12324654 : 98

234769O1 : 45 : Incorrect ID : not included

12563792 : 49

74537299 : 7I : Incorrect mark : not included

99834511 : 50

77625489 : 56

55274559 : 63

22009643 : 71

72578129 : 51

17 -----THE ARRAY STORED DOUBLED-----

Aucun commentaire:

Enregistrer un commentaire