Search code examples
phpjqueryhtmlphpquery

What is the phpQuery equivalent of the JQuery unwrap?


I have HTML with nested <div> tags. I have tried

$doc->find('div div')->unwrap();

and

foreach($doc['div div'] as $div_div)
 {
  pq($div_div)->unwrap();
 }

But this returned the following error:

Uncaught exception 'Exception' with message 'Method 'unwrap' doesnt exist'

I need to figure out how to remove the outer-most DIV tag and retain everything inside.

Here is the HTML

<div style="text-align: justify;">
    <div style="font-family: Times'; font-size: 13pt; text-align: center;">
          ARTICLE 1 - FAMILY, BENEFICIARIES, AND TRUST PURPOSE
    </div>
    <div style="text-align: justify;">1.1<span class="Apple-tab-span">  </span<b>Family</b>
    </div>
</div>

Solution

  • try using contentsUnwrap(),

    $doc->find('div div')->contentsUnwrap();