|
<html><head><meta http-equiv=/"Content-Type/" content=/"text/html; charset=utf-8/">
<title>如何使用String类提取HTML</title>
<script language=/"JavaScript/" type=/"text/JavaScript/">
</script>
<body>
</body>
</html>
截取 <title> </title>中的字符串
代码如下:
<?php
$tq="<html><head><meta http-equiv=/"Content-Type/" content=/"text/html; charset=gb2312/">
<title>如何使用String类提取HTML</title>
<script language=/"JavaScript/" type=/"text/JavaScript/">
</script>
<body>
</body>
</html>
";
echo $tq;
$starttitle="<title>";
$endtitle="</title>";
$start=strpos($tq,$starttitle); //检索<title>在字符串中首次出现的位置。
$end=strpos($tq,$endtitle);
echo substr($tq,($start+strlen($starttitle)),$end);
?> |
|
|