How do I find an occurrence in a string after a specific occurrence in php?

Discussion in 'Programming' started by Glenn, Sep 5, 2014.

to remove all ads.
  1. Glenn

    Glenn Member

    I'm looking for
    $startpos = strpos($page, '<div id="yada yada"') + 7;

    I want to set $endpos to the position of the closing div, "</div>". If I do that, it will read the first closing div and not the one that I want. How do I find the next /div after the start one I found?
  2. chrishirst

    chrishirst Well-Known Member Staff Member

    Count the number of opening div tags following the one you want then find the n+1 instance of the closing div tags.

Share This Page