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

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

WBOY
WBOYOriginal
2016-06-08 17:29:521526Durchsuche

采集在现在的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;

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Vorheriger Artikel:php 取得fck内容图片代码Nächster Artikel:php 文件重命名 rename