本文實例講述了php通過兩層過濾獲取留言內容的方法。分享給大家供大家參考,具體如下:
//兩層過濾,獲取留言的內容$str='<div id="read_111111" style="font-size:14px;line-height:150%;padding:10px;">測試文字1<div id="lwd_12223"><h6 class="quote"><span class="s3 f12 fn">樓主留言:</span></h6><blockquote class="blockquote">測試文字2..</blockquote></div></div>';//$str='<div id="read_111111" style="font-size:14px;line-height:150%;padding:10px;">厲害</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程序設計有所幫助。
新聞熱點
疑難解答
圖片精選