Php regular expression matches the div with class in html and selects the method of the content, classdiv. Php regular expression matches the div with a class in html and selects the method of the content. classdiv this article describes the php regular expression matches the div with a class in html and selects the method of the content. I will share with you the php regular expression matching method of p with class in html and select the content method, classp
This example describes how to use php regular expression to match the class p in html and select the content. Share it with you for your reference. The specific analysis is as follows:
First look at the html code:
The code is as follows:
Tide tableData is for reference only
Hrs) |
00:58 |
05:20 |
13: 28 |
|
High tide (cm) |
161 |
75 |
288 |
127 |
Time zone:-1000 (East 10) tidal high reference: 174 at average sea level
This is a part of the source program. in order to make it easy to understand, a large part of the program is deleted.
Content in Block p
On the homepage, use file_get_content or curl to obtain the content. I use curl.
The code is as follows:
$ Ch = curl_init ();
Curl_setopt ($ ch, CURLOPT_URL, $ url );
Curl_setopt ($ ch, CURLOPT_POST, 1 );
Curl_setopt ($ ch, CURLOPT_HEADER, 0 );
Curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, 1 );
Curl_setopt ($ ch, CURLOPT_POSTFIELDS, $ data );
$ Return = curl_exec ($ ch );
Curl_close ($ ch );
$ Regex4 = "/
.*? <\/P>/ism ";
If (preg_match_all ($ regex4, $ return, $ matches )){
Print_r ($ matches );
} Else {
Echo '0 ';
}
In this way, you can understand PHP code and print the results.
I hope this article will help you with php programming.
Examples in this article describes how to match the class p in html with php regular expressions and select the content. Share it with you...