substr($variable, rindex($variable,$tofind), length($tofind), $replacement) if rindex($variable,$tofind) > -1;