in reply to Removing underscores.

You have to come up with some kind of logical criteria. Why is the last underscore unacceptable? Determine that and we might able to help you. By your question above, I could simply say that if you had
$txt = "This_is_a_song_.mp3";
and you want it to be "This_is_a_song.mp3". Do this:
$txt = "This_is_a_song.mp3";
but that's probably not very helpful.