Home >Backend Development >PHP Tutorial >PHP collection code example_PHP tutorial

PHP collection code example_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 14:52:18933browse

function preg_substr($start, $end, $str) // Regular interception function  
{  
$temp = preg_split($start, $str); $temp = preg_split($start, $str);
$content = preg_split($end, $temp[1]);
Return $content[0];
}
function str_substr($start, $end, $str) // String interception function  
{  
$temp = explode($start, $str, 2); $temp = explode($start, $str, 2);
$content = explode($end, $temp[1], 2); $content = explode($end, $temp[1], 2);
Return $content[0];
}
//----------------Usage Example----------------
$str = iconv("UTF-8", "GB2312", file_get_contents("http://www.bkjia.com"));
echo ('Title: ' . str_substr("", "", $str)); // Extract title through string
echo ('Author: ' . preg_substr("/userid=d+">/", "/ echo ('Content: ' . str_substr('

', '
', $str)); //Of course the content cannot be less
?>
 

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371583.htmlTechArticle?php function preg_substr($start, $end, $str) // Regular interception function { $temp = preg_split ($start, $str); $content = preg_split($end, $temp[1]); return $content[0]; } function str_su...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn