你可以使用
explode()
作用
$content = file_get_contents("http://www.demo.com");
$explodedContent = explode("<title>", $content);
$explodedExplodedContent = explode("</title>", $explodedContent[1]);
echo $explodedExplodedContent[0]; // title of that page.
你可以把它变成一个函数;
function contentBetween($beginStr, $endStr, $contentURL){
$content = file_get_contents($contentURL);
$explodedContent = explode($beginStr, $content);
$explodedExplodedContent = explode($endStr, $explodedContent[1]);
return $explodedExplodedContent[0];
}
echo contentBetween("<title>", "</title>", "http://www.demo.com"); // usage.
查看有关的更多信息
爆炸()
传真:
http://php.net/manual/tr/function.explode.php