src/Str.php
public static function replaceFirst($search, $replace, $subject)
    {
        if ($search == '') {
            return $subject;
        }

        $position = mb_strpos($subject, $search);

        if ($position !== false) {
            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search));
        }

        return $subject;
    }
public static function replaceFirst($search, $replace, $subject)
    {
        if ($search == '') {
            return $subject;
        }

        $position = mb_strpos($subject, $search);

        if ($position !== false) {
            return mb_substr($subject, 0, $position).$replace.mb_substr($subject, $position + mb_strlen($search));
        }

        return $subject;
    }
public static function replaceFirst ( $ search , $ replace , $ subject ) { if ( $ search == '' ) { return $ subject ; } $ position = mb_strpos ( $ subject , $ search ) ; if ( $ position !== false ) { return mb_substr ( $ subject , 0 , $ position ) . $ replace . mb_substr ( $ subject , $ position + mb_strlen ( $ search ) ) ; } return $ subject ; }
Replace the first occurrence of a given value in the string.

@param  string  $search
@param  string  $replace
@param  string  $subject
@return string
Replace the first occurrence of a given value in the string .