首页 > 解决方案 > 为什么我的产出价值翻了一番?如何在不加倍的情况下存储每个文件的确切值?

问题描述

 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));
     

输出:

12345678 : 56

3456782:67:不正确的 ID:不包括在内

12324654 : 98

23476901:53

12563792:49

74537299:7

99834511:50

77625489 : 56

55274559:63

22009643:711:不正确的标记:不包括在内

8 ---存储的数组

12345678 : 56

34567822:67

12324654 : 98

234769O1:45:不正确的 ID:不包括在内

12563792:49

74537299:7I:不正确的标记:不包括

99834511:50

77625489 : 56

55274559:63

22009643 : 71

72578129 : 51

17 -----存储的数组加倍-----

标签: phploopsif-statement

解决方案


推荐阅读