PHP regular matches title caption text

Source: Internet
Author: User

 ////////////////////////////////////////////////////////////////////////////////////////////////////////// /*incoming Article ID resolves the article title*/ //////////////////////////////////////////////////////////////////////////////////////////////////////////  Public functionGetbooknamebyid ($aid){  //Initialize Curl  $ch=Curl_init (); //URL  $url= ' http://www.motie.com/book/'.$aid; if(Is_numeric($aid)){  //Regular expression matching  $ru= "/; }  Else{  //<title> Zombie Outbreak of the Family Survival Road _ Chapter One zombie outbreak for my Friendship Tunes update ~_ iron </title>$ru = "/<title> (. *) <\/title>/"; }  //setting options, including URLscurl_setopt ($ch, Curlopt_url,$url); curl_setopt ($ch, Curlopt_returntransfer, 1);//do not output content automaticallycurl_setopt ($ch, Curlopt_header, 0);//do not return header informationcurl_setopt ($ch, Curlopt_connecttimeout_ms, 0); //Perform Curl  $output= Curl_exec ($ch); //Error Hints  if(Curl_exec ($ch) ===false){    die(Curl_error ($ch)); }  //Check to see if an error has occurred  if(Curl_errno ($ch)){  Echo' Curl error: '. Curl_error ($ch); }  //releasing the curl handleCurl_close ($ch); $arr=Array(); Preg_match_all($ru,$output,$arr);
  The first one is the complete match, the second match is the plain text of the title tag.
return $arr [1][0];
   // ////////////////////////////////////////////////////////////////////////////////////////////////////////     

PHP regular matches title caption text

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.