public static function replaceLastOccurrence($search, $replace, $subject)
    {
        $pos = strrpos($subject, $search);

        if($pos !== false)
        {
            $subject = static::mb_substr_replace($subject, $replace, $pos, mb_strlen($search));
        }

        return $subject;
    }
public static function replaceLastOccurrence($search, $replace, $subject)
    {
        $pos = strrpos($subject, $search);

        if($pos !== false)
        {
            $subject = static::mb_substr_replace($subject, $replace, $pos, mb_strlen($search));
        }

        return $subject;
    }
public static function replaceLastOccurrence ( $ search , $ replace , $ subject ) { $ pos = strrpos ( $ subject , $ search ) ; if ( $ pos !== false ) { $ subject = static :: mb_substr_replace ( $ subject , $ replace , $ pos , mb_strlen ( $ search ) ) ; } return $ subject ; }
Utility method to replace only the last occurrence in a string

@param string $search
@param string $replace
@param string $subject
@return string
Utility method to replace only the last occurrence in a string