php過濾a標簽
A. php 去掉a標簽中的鏈接
只是保留內容,你把下面的代碼改改就行了:
<?php
$html_with_a_tags ='<a href="卜緩困www..com" target="_blank" class="keylink">玉石哪基</a>';
//保存一個超鏈接字元串變數,php當字元串處理
$txt = strip_tags($html_with_a_tags);
//用strip_tags去掉html標簽
echo $txt;
//輸出結果
?>
至於你的說什麼object,把它調進去就行型念了
B. 怎麼用PHP正則去掉html標簽,<img><a><p><br>除外
可以使腔緩用strip_tags函數
<?php
$rr = strip_tags($str,'<塌圓昌img>團扒<a><p><br>');
echo $rr;
?>
C. php怎麼去除mysql資料庫中指定表,指定欄位的所有A標簽
先查詢出來 $rows=select ****** 你要替換的欄位 和id
然後更新就是了
foreach($rows as $k=>$v){
去除a 標簽 $str=preg.replace('/\>\><a.+?>A<\/a>/','',$v['更改的欄位']);
更新資料庫 update table set 你要更改的欄位=$str where id='{$v['id']}'
}
D. php 正則過濾掉 指定的a標簽
我這個更好
<?php
$str='<a class="qc" href="/car">汽車</a><a class="db" href="/car">大巴</a><a class="qc" href="/car">汽車</a>';
$str=preg_replace("/<a class=\"qc\" href=\"(.*)\">(.*)<\\/a>/iU","$2",$str); //過濾script標簽
echo $str;
?>
E. php 用正則表達式,去除A標簽
stringstrip_tags ( string$str [, string$allowable_tags ] )
從字元串中去除 HTML 和 PHP 標記
F. 求一個php簡單的過濾除<br>,<p>,<style>html標簽的正則或方法
針對你這個<a>123</a>的例子的
$a=<<<str
<a>123</a>
str;
$preg ="/<(a)>(.*?)<\/(\1)>/is";
$str = preg_replace($preg, "<a>\\2</a>", $a);
echo $str;
除此之外PHP還有一個 過濾標簽的函數 你可以看一下手冊
G. php正則匹配所有a標簽,並刪除
試試這個
preg_replace('/(<a.*?>[sS]*?</a>)/','',$str);