Here's my code:
$long = str_repeat('a very long string text', 100); // try changing 100 to 5000
$str = <<<STR
<abc>a short string text</abc>
<abc>$long</abc>
STR;
preg_match_all('@<abc>([^<>]+)</abc>@sU', $str, $matched);
print_r($matched);
And it works totally as expected. However, after you have changed 100 repetitions to 5000, run
print_r($matched);
And you will only get results for the short string occurrence.
My question is how to make preg_match or preg_match_all to work with large string texts (as large as 1MB or larger)?