Send text and lenth to output for HTML

<?
function SafGetDoneBodyText($mytext,$after=0,$mytextlenth=0) { // send text and replace chr13 with br and number of text
$mytext = stripslashes($mytext);
if (
$mytextlenth) {
$mytext = substr($mytext,0,$mytextlenth);
}
$mytext = str_replace(chr(13),"<br>",$mytext);
$mytext = str_replace("\n","",$mytext);
return $mytext;
}
?>