Let's say I have:
$line = "{This is my {sentence|words} I wrote.}"
Output:
This is my sentence I wrote. This is my words I wrote.
But the regex must match deep and nested values ββand separate these values, for example:
$line = "{This is my {sentence|words} I wrote on a {sunny|cold} day.}";
Output:
This is my sentence I wrote on a sunny day. This is my sentence I wrote on a cold day. This is my words I wrote on a sunny day. This is my words I wrote on a cold day.
My first, although he did it over an explosion, as in the code below, but the result does not fit:
$res = explode("|", $line);
Advice? Thanks.
EDIT: Something on these lines:
$line = "{This is my {sentence|words} I wrote on a {sunny|cold} day.}"; $regex = "{[^{}]*}"; $match = []; preg_match($regex, $line, $match); var_dump($match);
As already mentioned, it can go to infinite, without restriction, something in a suitable cycle.
source share