Regular matching nested div, PHP implementation ~
The following HTML string:
$str = '
1111111111
2222222222
Link1
1111111111
2222222222
';
Results that need to be matched:
Match the content in, that is:
1=>
1111111111
2222222222
Link1
2=>
1111111111
2222222222
PHP program implementation, online, etc. ~
------Solution--------------------
References:
$patten = '/((*))/';
Preg_match_all ($patten, $str, $match);
It's not that simple. Because there will be more than one, you should start looking from the inner layer, and then one layer at a level, knowing that the match is so far
------Solution--------------------
$str = '
1111111111
2222222222
Link1
1111111111
2222222222
';
if (Preg_match_all (' #]*> (? >[^]+
------Solution--------------------
.+?
------Solution--------------------
------Solution--------------------
(? R) *) #is ', $str, $matches)) {
Print_r ($matches);
}
?>