= 0) $buf[$lvl] .= '{'; $lvl++; $buf[$lvl] = ''; break; case '}': $callback($buf[$lvl]); $lvl--; if($include&& $lvl >= 0) $buf[$lvl] .= '}'; break; default: for($j = 0; $j <= $lvl; $j++) $buf[$j] .= $c; break; } } } function display($match) { echo $match . "\r\n"; } process('Hello {world of {warcraft}}', 'display'); process('Hello {world of {warcraft}}', 'display', true); process('Du drikker {cola} med Lars i en {børnehave}.', 'display'); ?>