Answer the question
In order to leave comments, you need to log in
How to cut an entire block of html using php?
Good afternoon!
I get the html code of a specific page. Inside there is this structure:
<div class="container">
<div class="box">
..... (some code)
</div>
<div class="box">
..... (some code)
</div>
<div class="box">
..... (some code)
</div>
<div class="box">
..... (some code)
</div>
</div>
</div>
, but before that, there is also </div>
. Answer the question
In order to leave comments, you need to log in
https://regex101.com/r/iIGpJV/1
$content = '<div class="container">
<div class="box">
..... (some code)
</div>
<div class="box">
..... (some code)
</div>
<div class="box">
..... (some code)
</div>
<div class="box">
..... (some code)
</div>
</div>';
preg_match("#<div class=\"container\">(.+?)\n<\/div>#is", $content, $res);
var_dump($res);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question