Questions about PHP Regular matching to take out data
The following is a partial processing of source code
$exam = Curl_init ("http://exam.hhit.edu.cn/fgquery.do?status=lowquery&tsid=2012120348");
curl_setopt ($exam, Curlopt_returntransfer, true); Get Data back
curl_setopt ($exam, Curlopt_binarytransfer, true); Gets the data back when Curlopt_returntransfer is enabled
$exam =curl_exec ($exam);
$exam = Preg_replace ("'
]*?> ' si ', ' ", $exam);
$exam = Preg_replace ("'
]*?> ' si", "", $exam);
$exam = Preg_replace ("'
]*?> ' si", "", $exam);
$exam = Str_replace ("", "{tr}", $exam);
$exam = Str_replace ("", "{td}", $exam);
Remove HTML Tags
$exam = Preg_replace ("' <[/!") *? [^<>]*?> ' si ', ' ", $exam);
Remove whitespace characters
$exam = Preg_replace ("' ([RN]) [s]+ '", "", $exam);
$exam = Preg_replace ('//', "", $exam);
$exam = Str_replace ("", "" ", $exam);
$exam = Str_replace ("", "" ", $exam);
$exam = Explode (' {tr} ', $exam);
Array_pop ($exam);
Print_r ($exam);
?>
What I want is to take out the following piece of data into the array, do not know how to write, the first contact with the regular feel do not understand, thank you to the great gods!
Number {TD}
Course {TD}
Date {TD}
Time {TD}
class {TD}
Examination Room {TD}
Classroom Teacher {TD}
1{TD}
Fluid Dynamics {TD}
2014-11-0600:00:00.0
{TD}
14:00-16:00{TD}
Civil 122{TD}
Ⅲ-209{TD}
Sinina {TD}
------to solve the idea----------------------
That's what you're going to do.
Print_r (Array_map (NULL, explode (' {TD} ', $exam []), explode (' {TD} ', $exam [20]));
Array
(
[0] = = Array
(
[0] = = number
[1] = 1
)
[1] = = Array
(
[0] = Course
[1] = Fluid mechanics
)
[2] = = Array
(
[0] = Date
[1] = 2014-11-0600:00:00.0
)
[3] = = Array
(
[0] = time
[1] =
)
[4] = = Array
(
[0] = Class
[1] = Civil Engineering 122
)
[5] = = Array
(
[0] = = Examination Room
[1] =>ⅲ-209
)
[6] = = Array
(
[0] = = Instructor
[1] = Sinina
)
[7] = = Array
(
)
)
It's still like that.
Print_r (Array_combine (Explode (' {TD} ', $exam []), explode (' {TD} ', $exam [20]));
Array
(
[No.] = 1