regex - PHP basic regular expression -


this question has answer here:

for example i've kind of content

<div id="t1" class="tt" tag='t2"><div class="t3">tee</div><a href='#'>test</a><span>test</span><div>asdf</div></div>  <div id="t1" class="tt" tag='t2"><div class="t3">tee</div><a href='#'>test</a><span>test</span><div>asdf</div></div> 

i trying use preg_match content between parent div, here parent divs means <div id="t1". use preg_match or there other way data between divs?

a regular expression wrong tool job. want dom parser.

$dom = new domdocument; $dom->loadhtml($html);  $t1 = $dom->getelementbyid('t1'); echo $t1->nodevalue; 

this return text, if want innerhtml, try this:

$dom = new domdocument; $dom->loadhtml($html);  $t1 = $dom->getelementbyid('t1');  $innerhtml = ''; foreach($t1->childnodes $child){     $innerhtml .= $dom->savehtml($child); } echo $innerhtml; 

Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -