-1

重複の可能性:
iframe を削除するとエラーが発生するが、タグ p を削除できない

サンプルコードがあります:

$content = '<p><iframe width="640" scrolling="no" height="150" frameborder="1" marginheight="0" marginwidth="0" src="http://test.html"></iframe></p><p>Hello world</p>';
$text = preg_replace('/<p>\s*(<iframe src="http://test.html" .*>*.<\/iframe>)\s*<\/p>/iU', '', $content);
echo $text;

この iframe の結果を削除する修正方法は次のとおりです。<p>Hello world</p>

4

1 に答える 1

0
$text = preg_replace('|<iframe [^>]*(src="http://test.html")[^>]*|', '', $content);
于 2012-08-17T03:36:52.253 に答える