Codice PHP:
echo substr($str,0,strlen(trim($str))-1).'.'