DOM php delete all tags by tag name

前端 未结 1 321
忘了有多久
忘了有多久 2021-01-12 15:23

I\'m having a problem with a script I\'ve been using for some time and it worked for me until I hit this problem.

I have a script with which I\'d like to delete all

相关标签:
1条回答
  • 2021-01-12 16:01

    Try this way:

    $doc->loadHTML($a);
    $list = $doc->getElementsByTagName("p");
    
    while ($list->length > 0) {
        $p = $list->item(0);
        $p->parentNode->removeChild($p);
    }
    
    0 讨论(0)
提交回复
热议问题