怎么在php中通过两层过滤获取留言内容

本篇文章给大家分享的是有关怎么在php中通过两层过滤获取留言内容,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。

具体如下:

//两层过滤,获取留言的内容
$str='<div id="read_111111" >测试文字1<div id="lwd_12223"><h7 class="quote"><span class="s3 f12 fn">楼主留言:</span></h7><blockquote class="blockquote">测试文字2..</blockquote></div></div>';
//$str='<div id="read_111111" >厉害</div>';
//preg_match("/[^.*](style=\"font-size:14px;line-height:150%;padding:10px;\">)(.*)<\/div>.*$/",$str, $str_arr);
preg_match("/[^.*]id=\"read_[0-9]{8}\" (style=\"font-size:14px;line-height:150%;padding:10px;\">)(.*)<\/div>.*$/",$str, $str_arr); //修复一下过滤楼主的留言
//print_r($str_arr);
if($str_arr[1]=="style=\"font-size:14px;line-height:150%;padding:10px;\">"){
  echo "find!";
  //<div id="
  $str_arr_2=$str_arr[2];
  $str_arr_2_arr=explode("<div id=\"",$str_arr_2);
  $str_arr_2_arr_0=$str_arr_2_arr[0];
  }else{
    //echo "not find!";
  }
echo $str_arr_2_arr_0;

以上就是怎么在php中通过两层过滤获取留言内容,小编相信有部分知识点可能是我们日常工作会见到或用到的。希望你能通过这篇文章学到更多知识。更多详情敬请关注行业资讯频道。