function preg_substr($start, $end, $str) // 正則截取函數
{
$temp = preg_split($start, $str);
$content = preg_split($end, $temp[1]);
return $content[0];
}
function str_substr($start, $end, $str) // 字串截取函數
{
$temp = explode($start, $str, 2);
$content = explode($end, $temp[1], 2);
return $content[0];
}
// ---------------- 使用執行個體 ----------------
$str = iconv("UTF-8", "GB2312", file_get_contents("http://www.bkjia.com"));
echo ('標題: ' . str_substr("", "", $str)); // 通過字串提取標題
echo ('作者: ' . preg_substr("/userid=d+">/", "/echo ('內容: ' . str_substr('', '', $str)); //內容當然不可以少
?>
http://www.bkjia.com/PHPjc/371583.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/371583.htmlTechArticle?php function preg_substr($start, $end, $str) // 正則截取函數 { $temp = preg_split($start, $str); $content = preg_split($end, $temp[1]); return $content[0]; } function str_su...