Collection of website regular expressions and result output problems

Source: Internet
Author: User
Collection of website regular expressions and result output problems collection of output errors, see if it is a regular statement problem



Function compute ($ remote_server, $ post_string) {$ ch = curl_init (); curl_setopt ($ ch, CURLOPT_URL, $ remote_server); curl_setopt ($ ch, CURLOPT_POSTFIELDS, 'mypost = '. $ post_string); curl_setopt ($ ch, CURLOPT_RETURNTRANSFER, true); curl_setopt ($ ch, CURLOPT_USERAGENT, "Jimmy's CURL Example beta"); $ data = curl_exec ($ ch ); curl_close ($ ch); return $ data;} $ string = request_by_curl ("http://www.bwlc.net/bulletin/keno.html", 80); $ pat = '/\[\ S \ S] *? \
 
  
(.*?) \ <\/Td \> [\ s \ S] *? \
  
   
(.*?) \ <\/Td \> [\ s \ S] *? \
   
    
(.*?) \ <\/Td \> [\ s \ S] *? \
    
     
(.*?) \ <\/Td \> [\ s \ S] *? \ <\/Tr \>/I '; preg_match_all ($ pat, $ string, $ outstr); foreach ($ outstr as $ key => $ value) {echo "th ". $ outstr [$ key] [1]. "period, the result is :". $ outstr [$ key] [2]. "Frisbee :". $ outstr [$ key] [3]. "Time :". $ outstr [$ key] [4]. "\ n ";}
    
   
  
 


Reply to discussion (solution)

The format of the matching result array is incorrect.

Foreach ($ outstr [0] as $ key => $ value) {echo "th ". $ outstr [1] [$ key]. "period, the result is :". $ outstr [2] [$ key]. "Frisbee :". $ outstr [3] [$ key]. "Time :". $ outstr [4] [$ key]. "\ n ";}
Issue 1: Lottery Results: 712,522nd, 712,521st, 01 Time: 712,520th, Time, 712,519th, 02 Time: issue, Awards, frisbee, 712,518th,: 01 Time: Issue. Awards, 712,517th, 58 Frisbee: 03 Time: issue 712,516th, lottery results: 27,40, 13,76, 38,52, 24,75, 44,49, 14,72, 65,35, 712,515th, 67,07, 57,71 Frisbee: 01 Time: issue, results: 712,514th, 03 Time:,. Results, 712,513rd, 01, 712,512nd, 02 Time, 712,511st,: 10 Time: issue, the results of the awards are:, 15: 01 Time: issue 712,510th, the results are:, 39 Time: 01: issue 712,509th, lottery results: 712,508th, 22, results: 712,507th, 01 Time, 712,506th, 02 Time, 712,505th, 01 Time, 24,45, 57,19, 712,504th 35 Frisbee: 03 Time: issue, the award results are:, 74: 02 Time: issue 712,503rd, the results of the award are: 29,20, 67,45, 34,09, 35, 31, 79,13: 01 Time: issue 712,502nd: Lottery Results: 49,60, 19,30, 07,76, 27,45, 17,70, 37,44, 11,61, 56,21, 712,501st, 58,06 Frisbee: 03 Time: issue, awards: 712,500th, 02 Time, 712,499th, 02 Time, 712,498th, 57,66, 08,47, 39,78 Frisbee: 04 Time: 11th issue. prize winners: 712,497th, 08: 03 Time: 712,496th issue, the results of the award are: 15, 48, 01 Time: 01:, 712,495th, 712,494th, 04 Time, awards: 712,493rd, 02 Time, 08

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.