coba ini
$text = '[code]lorem ipsum
lorem
lorem ipsum
';
$text = preg_replace_callback(
'/\[code\](.+?)\[\/code\]/',
create_function(
// single quotes are essential here,
// or alternative escape all $ as \$
'$matches',
'return htmlentities($matches[1]);'
),
$text
);
echo $text;
[/code]