GeertDD wrote:You gave us two different strings as the starting point. Which one to use?
{test{hello},{world}}
{test,{hello},{world}}
Starting from the second string, I came up with the regex below.
Code: Select all
preg_match_all('/(?<=,)(?:{.+?})/', '{test,{hello},{world}}', $matches);
// contents of $matches:
Array
(
[0] => Array
(
[0] => {hello}
[1] => {world}
)
)
2nd one is correct, you got the part I'm stuck on but this might be more complicated than what I was expecting. This is for my template system I'm working on, I don't think I would be able to figure out how to translate {hello} and {world} before {test, XXX, YYY}
Like say test was a function and XXX and YYY were values used in the function the XXX and YYY has to be defined before the test.
Example:
define("hello", "Power Puff");
define("world"," Girls");
function test($value1, #value2){
echo $value1 . $value2;
}
in template file when you do
I like watching the
{test,{hello},{world}}! Specially like Bubbles!!
it should result in
I like watching the
Power Puff Girls! Specially like Bubbles!!
.