Hab's nicht weiter durchdacht oder -getestet, aber versuch mal
PHP-Code:
<?php
$abbrevs = array('php', 'html', 'z.B.');
$text = 'Hallo, das hier z.B. ist ein Text. PHP. php!
[b]HTML[/b], PHP und es testPHP, [i]dass[/i] er einen...';
function patternTest($abbr, $text)
{
$abbr = array_map('preg_quote', $abbr);
$abbr = join('|', $abbr);
$pattern = '!(?<=^|\W)('.$abbr.')(?=\W|$)!i';
echo preg_replace($pattern, '<u>$1</u>', $text);
}
patternTest($abbrevs, $text);
?>
p.s.: bbCode wird hier ja innerhalb von [php] ersetzt. Dös's ja bled
