$str = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
echo "原字符串:".$str."<br>"
//按各种方式进行截取
$str1 = substr($str,5)
echo "从第5个字符开始取至最后:".$str1."<br>"
$str2 = substr($str,9,4)
echo "从第9个字符开始取4个字符:".$str2."<br>"
$str3 = substr($str,-5)
echo "取倒数5个字符:".$str3."<br>"
$str4 = substr($str,-8,4)
echo "从倒数第8个字符开始向后取4个字符:".$str4."<br>"
$str5 = substr($str,-8,-2)
echo "从倒数第8个字符开始取到倒数第2个字符为止:".$str5
?>
$strPath = '这个html的路径'curl_setopt ($ch, CURLOPT_URL, $strPath)
curl_setopt ($ch, CURLOPT_HEADER, 1)
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1)
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout)
$contents = curl_exec($ch)
if($contents){
$intH1start= strpos($contents, '<h1>')//这样的前提是这个页面只有一个<h1>标签
$intH1end = strpos($contents, '</h1>')//如果有多个则会取不准
$strH1 = substr(contents,$intH1start,$intH1end)
}
试试以上的方法,如果可以的话请采纳,有问题的话,请追问或留言