A few questions about regular expressions, thank you very much.

Source: Internet
Author: User
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 "
";
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.