in reply to Replace the last letter

substr($variable, rindex($variable,$tofind), length($tofind), $replace +ment) if rindex($variable,$tofind) > -1;