The question about regular expressions, thank you very much!
The following is the crawl to the page, want to pass the regular expression function to take out the inside of the teacher timetable arrangement information, I hope you heroes to help, thank you.
http/1.1 OK
Connection:close
Date:thu, 07:44:28 GMT
Server:yxlinkwaf
X-powered-by:asp.net
x-aspnet-version:1.1.4322
Cache-control:private
content-type:text/html; charset=gb2312
content-length:11062
<title>Modern Teaching Management Information system</title>
Viewastext>
------to solve the idea----------------------
Include ' simple_html_dom.php ';//This you can download an online
$dom =new simple_html_dom ();
To convert content to Utf-8 to handle
$dom->load ($content);
$names = $dom->find (' select[id=js] ');
$res =array ();
$res [' name ']= $names [0]->find (' option[selected=selected] ') [0]->text ();
$TABLETR = $dom->find (' table[id=table6] tr ');
foreach ($tabletr as $k = = $tr) {
foreach ($tr->find (' TD ') as $k 1=> $td) {
if ($k 1!==0) {
$info [$k] [$k 1]= $td->text ();
}
}
}
Optimize your data
foreach ($info as $k = = $v) {
if ($k ==1) {
Unset ($info [1]);
}
if (count ($v) ==8) {
Unset ($v [1]);
}
$info [$k]=array_values ($v);
}
$week = $info [0];
unset ($info [0]);
Organization data
foreach ($info as $v) {
foreach ($v as $k = = $v) {
$tmp [$week [$k]][]= $v;
}
}
$res [' info ']= $tmp;
echo "";
Print_r ($res);
echo "
";
/*
Array
(
[Name] = Wang Feng
[INFO] = = Array
(
[Monday] = = Array
(
[0] = =
[1] = =
[2] = = Linear algebra b
1-17 (3,4)
Wang Li
Audio-Visual Building 205
ITCSC 14 (1)
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
[Ten] =
)
[Tuesday] = = Array
(
[0] = =
[1] = =
[2] = =
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
[Ten] =
)
[Wednesday] = = Array
(
[0] = =
[1] = =
[2] = =
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
[Ten] =
)
[Thursday] = = Array
(
[0] = =
[1] = =
[2] = = Linear algebra b
1-17 (3,4)
Wang Li
Audio-Visual Building 205
ITCSC 14 (1)
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
[Ten] =
)
[Friday] = = Array
(
[0] = =
[1] = =
[2] = =
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
[Ten] =
)
[Saturday] = = Array
(
[0] = =
[1] = =
[2] = =
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
)
[Sunday] = = Array
(
[0] = =
[1] = =
[2] = =
[3] = =
[4] = =
[5] = =
[6] = =
[7] = =
[8] = =
[9] = =
)
)
)
*/
Process the course information according to your own needs
$txt = <<
<>
Linear algebra B
1-17 (3,4)
Wang Li
Audio-Visual Building 205
ITCSC 14 (1)
EOF;
$arr =explode (Php_eol, $txt);
echo "";
Print_r ($arr);
echo "
";