- preg_replace_callback: documentation ( source)
- preg_match: documentation ( source)
- trim: documentation ( source)
<?php
$test =
'YO_{
YO_{
YO_{
McDonalds.
}
}
}';;
$test = preg_replace_callback($p = '/YO_\{(.*)\}/s', $f = function($matches) use (&$f, &$p)
{
return preg_match($p, $matches[1])
?trim(preg_replace_callback($p, $f, $matches[1]))
:$matches[1];
}, $test);