Home > Article > Backend Development > PHP collection code example_PHP tutorial
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("
echo ('Author: ' . preg_substr("/userid=d+">/", "//", $str)); // Extract the author through regular expressions
echo ('Content: ' . str_substr('
?>