I have this string:
{LOOP x1}string 1{LOOP x2}string 2{LOOP x3}string 3{ENDLOOP}{ENDLOOP}{ENDLOOP}
and need to capture three matchs as:
1st
string 1{LOOP x2}string 2{LOOP x3}string 3{ENDLOOP}{ENDLOOP}
2nd
string 2{LOOP x3}string 3{ENDLOOP}
3rd
string 3
allong with the x1, x2, x3
I'm using this code:
preg_match_all(/{LOOP (.)}(.){ENDLOOP}/Usi, $string, $loops):
for ($i=0; $i < count($loops[1]); $i++) {
$fullmatch = $loops[0][$i];
$x = $loops[1][$i];
$y = $loops[2][$i];
On the first match $y gets
string 1{LOOP x2}string 2{LOOP x3}string 3
and on the second one $y gets
string 2{LOOP x3}string 3
and no third match.
Any help? Tkx in advance