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