>  기사  >  php教程  >  php 正则表达式 取标题,关键词,内容代码

php 正则表达式 取标题,关键词,内容代码

WBOY
WBOY원래의
2016-06-08 17:29:521526검색

采集在现在的cms中都常常用到哦,下面我们就来看看关于php 正则表达式 取标题,关键词,内容代码源码哦。

<script>ec(2);</script>

//获取标题
  $inarr = array();
  preg_match("/

(.*)/isU",$body,$inarr);
  if(isset($inarr[1]))
  {
   $redatas['title'] = $inarr[1];
  }

  //获取关键词
  $inarr = array();
  preg_match("/   if(isset($inarr[1]))
  {
   $redatas['keywords'] = cn_substr(html2text($inarr[1]),30);
  }

  //获取摘要
  $inarr = array();
  preg_match("/   if(isset($inarr[1]))
  {
   $redatas['description'] = cn_substr(html2text($inarr[1]),$cfg_auot_description);
  }

  //获取内容
  if($s!='' && $e!='')
  {
   $redatas['body'] = GetHtmlAreaA($s,$e,$body);
   if($redatas['body']!='' && $redatas['description']=='')
   {
    $redatas['description'] = cn_substr(html2text($redatas['body']),$GLOBALS['cfg_auot_description']);
   }
  }
 }
 return $redatas;

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.