How to cut a div?

$string ='
<div class="one">
<p>sdfg</p>
<p>sdfg</p>
<p>sdfg</p>

 <div class="two">
<p>sdfg</p>
<p>sdfg</p>
</div>
</div>';

function parse($p1, $p2, $p3) {
 $num1 = strpos($p1, $p2);
 $num2 = substr($p1, $num1);
 return substr($num2, 0, strpos($num2, $p3));
}

echo parse($string, '<div class="one">', '</div>');

You need to cut the whole unit with the class "one", the problem is that inside this block there might be other divas
So I started, and then not know..
March 19th 20 at 09:15
1 answer
March 19th 20 at 09:17
and somehow without libraries? or to make it so complicated? - meredith commented on March 19th 20 at 09:20
@meredith, can use DOMDocument , but with libraries easier. - dortha commented on March 19th 20 at 09:23

Find more questions by tags ParsingPHP