0

ドムドキュメントについて質問があります。

$htmlには次のようなものが含まれています

texts …paragraph..

<table class='test'>
   tr and td...
</table>

texts and more texts

私のhtml変数にテーブル要素があるかどうかを検出したい。その場合は、他のテキストを<p>タグで囲みます。

そうなる

<p>texts …paragraph..</p>

<table class='test'>
   tr and td...
</table>

<p>texts and more texts</p>

私のコードは

$doc = new DOMDocument();
$doc->loadHTML($htmlString);

$tables = $doc->getElementsByTagName('table');

     foreach ($tables as $table) {
        //I am not sure what to do next...
     }

誰かがこれについて私を助けることができますか? 本当にありがとう!

4

1 に答える 1