PHP sample code .? Phpfunctionpreg_substr ($ start, $ end, $ str) Regular truncation function {$ temppreg_split ($ start, $ str); $ contentpreg_split ($ end, $ temp [1]); return $ content [0];} functionstr_su Function preg_substr ($ start, $ end, $ str) // Regular truncation function
{
$ Temp = preg_split ($ start, $ str );
$ Content = preg_split ($ end, $ temp [1]);
Return $ content [0];
}
Function str_substr ($ start, $ end, $ str) // string truncation function
{
$ Temp = explode ($ start, $ str, 2 );
$ Content = explode ($ end, $ temp [1], 2 );
Return $ content [0];
}
// ---------------- Use instance ----------------
$ Str = iconv ("UTF-8", "GB2312", file_get_contents ("http://www.bkjia.com "));
Echo ('Title: '. str_substr (" ","", $ Str); // extract the title using a string
Echo ('Author: '. preg_substr ("/userid = d +"> /","/ Echo ('content: '. str_substr ('
','
', $ Str); // the content cannot be less.
?>
Http://www.bkjia.com/PHPjc/371583.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/371583.htmlTechArticle? Php function preg_substr ($ start, $ end, $ str) // Regular truncation function {$ temp = preg_split ($ start, $ str); $ content = preg_split ($ end, $ temp [1]); return $ content [0];} function str_su...