《PHP應用:php通過兩層過濾獲取留言內容的方法》要點:
本文介紹了PHP應用:php通過兩層過濾獲取留言內容的方法,希望對您有用。如果有疑問,可以聯系我們。
PHP學習本文實例講述了php通過兩層過濾獲取留言內容的方法.分享給大家供大家參考,具體如下:
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學習PS:這里再為大家提供一款非常實用的在線過濾工具:
在線html/js/css代碼過濾工具:
http://tools.jb51.net/code/htmlfilter
PHP學習更多關于PHP相關內容感興趣的讀者可查看本站專題:《php文件操作總結》、《PHP運算與運算符用法總結》、《PHP網絡編程技巧總結》、《PHP基本語法入門教程》、《php操作office文檔技巧總結(包括word,excel,access,ppt)》、《php日期與時間用法總結》、《php面向對象程序設計入門教程》、《php字符串(string)用法總結》、《php+mysql數據庫操作入門教程》及《php常見數據庫操作技巧匯總》
PHP學習希望本文所述對大家PHP程序設計有所幫助.
轉載請注明本頁網址:
http://www.snjht.com/jiaocheng/5868.html