$tpl = <<<end
{{crossLoopStart fromController->messages as message and increment|i every loop}}
wow, this is message number {{message->id}} and text is: {{message->text}}
{{crossLoopEmpty}}
oh no! You haven't any message!
{{crossLoopEnd}}
end;
preg_match('/\{\{crossLoopStart\s([a-zA-Z0-9>-]+)\s(?:as\s([a-zA-Z>-]+))?\s?and\s(?:([a-zA-Z0-9]+\|)?([a-zA-Z0-9]+)\s([a-z]+)\sloop)?\}\}'
. '(?:[\r\n]?(.+?)[\r\n]?\{\{crossLoopEmpty\}\})?'
. '(?:[\r\n]?(.+?)[\r\n]?\{\{crossLoopEnd\}\})/s', $tpl, $match);
var_dump($match);
array(8) {
[0]=>
string(224) "{{crossLoopStart fromController->messages as message and increment|i every loop}}
wow, this is message number {{message->id}} and text is: {{message->text}}
{{crossLoopEmpty}}
oh no! You haven't any message!
{{crossLoopEnd}}"
[1]=>
string(24) «fromController->messages»
[2]=>
string(7) «message»
[3]=>
string(10) «increment|»
[4]=>
string(1) «i»
[5]=>
string(5) «every»
[6]=>
string(74) «wow, this is message number {{message->id}} and text is: {{message->text}}»
[7]=>
string(31) «oh no! You haven't any message!»
}
position:absolute;
left:50%;
margin-left:-400px;
margin: 0 auto;