////////////////////////////////////////////////////////////////////////////////////////////////////////// /*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