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