Hallo,
Im Chat hat man mir zu preg_replace_callback() geraten und das funktioniert prima:
<?php
$line = '
foo <br />
bar [mycode]
ich bin es<br />
weil ich will
und du nicht<br />
[/mycode]
hallo <br />
test';
$line = preg_replace_callback(
'#\[mycode\](.+?)\[/mycode\]#is',
create_function(
'$matches',
'return "<pre>".str_replace("<br />", "", $matches[1])."</pre>";'
),
$line
);
echo $line;
?>
Grüße
Jeena Paradies