- nl2br: documentation ( source)
- str_replace: documentation ( source)
<?php
$full_text = "[b]This is a test[/b]
:)
:D
It's a boring test.";
$body = $full_text;
$body = nl2br($body);
$body = str_replace(
array(':)', ':D', '[b]', '[/b]'),
array('Emoticon Smile', 'Emoticon colon D', '<b>', '</b>'),
$body
);
echo $body;