可能性の重複:
php regexp: remove all attributes from an html tagPHPを使用してHTMLからすべてのスタイルを消去するにはどうすればよいですか?
$input = '<div style="font-size: 18px; line-height: 20px;" id="whatever">text</div>';
// ... some code here, probably regex
$desired_output = '<div id="whatever">text</div>';
私はPHPを使用して、上記の方法を行うのですか?
私は唯一の「style」属性を削除したい、すべての属性を削除したくありません! –
重複する質問には、スタイルタグを明確に削除する方法や、単一の属性のみを削除する方法の良い例がいくつかあります。 –
@RIMMERその質問の私の答えは正確にそれを示しています。また、要素から属性を削除する方法を説明する追加の重複もたくさんあります。 http://stackoverflow.com/questions/3820666/grabbing-the-href-attribute-of-an-a-element/3820783#3820783 – Gordon