Exemplo n.º 1
0
 /**
  * 查询某一班级的人数
  * @param string $college_code 学院代码
  * @param string $class_code 班级代码
  * @return number 班级的人数
  */
 function classMember($college_code, $class_code, array &$not_exit_student_arr = null)
 {
     $url = "http://dean.swjtu.edu.cn/public/QueryStudentInfo.jsp";
     $post_field = "query_action=query&query_type=class_code_all&check_type=name&student_id=&college_code={$college_code}&class_code={$class_code}";
     $curl = new CurlUtil();
     $html = $curl->post($url, $post_field);
     //返回的是一个html,需要正则匹配
     // 			echo $html;
     $pattern = '/<td height="28" align="center" bgcolor="#FFFFFF">(.*?)<\\/td>/si';
     preg_match_all($pattern, $html, $matches);
     if (empty($matches)) {
         return 0;
     }
     //处理无学籍情况
     $matchescount = count($matches[1]);
     $not_exit_student_arr = array();
     $count = 0;
     for ($i = 0; $i < $matchescount; $i++) {
         $row = $matches[1][$i];
         if (stripos($row, "无学籍") !== false) {
             //无学籍
             $student = new Student($matches[1][$i - 6], $matches[1][$i - 5], $matches[1][$i - 3], $matches[1][$i - 2], $matches[1][$i - 1], false);
             $not_exit_student_arr[$count] = $student;
             $count = $count + 1;
         }
     }
     return count($matches[0]) / 7;
 }