How do I remove

tag and its content from HTML using php

后端 未结 7 1227
既然无缘
既然无缘 2021-02-06 06:22

Below is the text I need to remove

tags from

Addiction, stress and subjective wellbeing

The need and signi

7条回答
  •  无人共我
    2021-02-06 06:52

    This code removes one p-tag:

    function parse($html) {
        $dom = new DOMDocument();
        @$dom->loadHTML($html);
        $ps = $dom->getElementsByTagName('p');
        //die('
    '.print_r($ps,1).'
    '); if ($ps->length === 1){ $p = $ps->item(0); return $p->nodeValue; } else { return ''; } }

提交回复
热议问题