0

I have problem with my php regular expression, this is my code:

<div class="editor-content">
    <h2 id="sec_1"><b>Description</b></h2>
    <p><strong>This is my long description</strong></p>

    <ul>
        <li>lorem ipsum</li>
        <li>lorem ipsum</li>
        <li>lorem ipsum</li>
    </ul>

    <h2 id="sec_2"><b>Details</b></h2>
    <p><strong>This is my long product details</strong></p>

    <ul>
        <li>lorem ipsum</li>
        <li>lorem ipsum</li>
        <li>lorem ipsum</li>
    </ul>
</div>

and i need: 1. Find all between

`<div class="editor-content">(.*?)</div>`
  1. If i have all between

    <div class="editor-content">(.*?)</div>

then i need get all section, i mean for example:

<h2 id="sec_1"><b>Description</b></h2>
    <p><strong>This is my long description</strong></p>

    <ul>
        <li>lorem ipsum</li>
        <li>lorem ipsum</li>
        <li>lorem ipsum</li>
    </ul>

I mean to find all sections in such a way that e.g. starts with sec_1 and preg_match gets everything until sec_2 starts, sec_2 starts, preg_match gets everything until sec_3.

Current i have this expression:

    $re = '/^<div class="editor-content">(.*?)</div>/';

    preg_match_all($re, $body, $matches);

// Print the entire match result
    var_dump($matches);

but he finds nothing.

PawelC
  • 1,128
  • 3
  • 21
  • 47

0 Answers0