Jump to content

[SOLVED] Extracting Content Between Divs


cursed

Recommended Posts

Hey all,

 

So I came across some code on the internet that can extract something from x to y.

function SimMyExtract($string, $openingTag, $closingTag)
{
    $string = trim($string);
    $start  = intval(strpos($string,$openingTag) 
                      + strlen($openingTag));
    $end    = intval(strpos($string,$closingTag));

    if($start == 0 || $end ==0)
    return false; // not found

    $mytext = substr($string,$start, $end - $start);
    return $mytext;
}

 

 

This works fine if I want it to extract something like

 

<div id="a"> content </div>, but I'm not sure how to get it to do something along the lines of <div id="a"><div id="b">content</div>more content</div>

 

Thanks in advance for your help.

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/180179-solved-extracting-content-between-divs/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.