src/Str.php
public static function replace(
        $input,
        $search,
        $replace,
        $caseInsensitive = false,
        $encoding = self::DEFAULT_ENCODING,
        &$count = null
    ) {
        return function_exists('mb_strlen')
            ? static::mbStrReplaceCaller($search, $replace, $input, $caseInsensitive, $encoding, $count)
            : (($caseInsensitive)
                ? (str_ireplace($search, $replace, $input, $count)) // @codeCoverageIgnore
                // excluded as reaching this line is environment dependent.
                : (str_replace($search, $replace, $input, $count)));
    }
public static function replace(
        $input,
        $search,
        $replace,
        $caseInsensitive = false,
        $encoding = self::DEFAULT_ENCODING,
        &$count = null
    ) {
        return function_exists('mb_strlen')
            ? static::mbStrReplaceCaller($search, $replace, $input, $caseInsensitive, $encoding, $count)
            : (($caseInsensitive)
                ? (str_ireplace($search, $replace, $input, $count)) // @codeCoverageIgnore
                // excluded as reaching this line is environment dependent.
                : (str_replace($search, $replace, $input, $count)));
    }
public static function replace ( $ input , $ search , $ replace , $ caseInsensitive = false , $ encoding = self :: DEFAULT_ENCODING , & $ count = null ) { return function_exists ( 'mb_strlen' ) ? static :: mbStrReplaceCaller ( $ search , $ replace , $ input , $ caseInsensitive , $ encoding , $ count ) : ( ( $ caseInsensitive ) ? ( str_ireplace ( $ search , $ replace , $ input , $ count ) ) // @codeCoverageIgnore // excluded as reaching this line is environment dependent. : ( str_replace ( $ search , $ replace , $ input , $ count ) ) ) ; }
Replaces a substring inside a string.

@param string $input           The input string
@param string $search          The substring to be replaced
@param string $replace         The substring replacement
@param bool   $caseInsensitive Whether the comparison should be case sensitive
@param string $encoding        The encoding of the input string
@param int    $count           If passed, this will be set to the number of replacements performed.

@return string   The string with the substring replaced
@SuppressWarnings(PHPMD.BooleanArgumentFlag)
Replaces a substring inside a string .