substr_replace

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Replace text within a portion of a string
<?php substr_replace(    array|string $string,    array|string $replace,    array|int $offset,    array|int|null $length = null): string|array
<?php     public function __invoke($string)

    {

        if (str($string)->endsWith(['.', '?', '!', ':'])) {

            return substr_replace($string, '', -1);

        }



        return $string;
<?php         if (str_contains($table, '.')) {

            $table = substr_replace($table, '.'.$this->tablePrefix, strrpos($table, '.'), 1);



            return collect(explode('.', $table))

                ->map($this->wrapValue(...))
<?php     protected function createIndexName($type, array $columns)

    {

        $table = str_contains($this->table, '.')

            ? substr_replace($this->table, '.'.$this->prefix, strrpos($this->table, '.'), 1)

            : $this->prefix.$this->table;



        $index = strtolower($table.'_'.implode('_', $columns).'_'.$type);
<?php         $position = strpos($subject, $search);



        if ($position !== false) {

            return substr_replace($subject, $replace, $position, strlen($search));

        }



        return $subject;
<?php         $position = strrpos($subject, $search);



        if ($position !== false) {

            return substr_replace($subject, $replace, $position, strlen($search));

        }



        return $subject;
<?php             $length = strlen($string);

        }



        return substr_replace($string, $replace, $offset, $length);

    }
<?php         if ($position !== false) {

            return [

                substr_replace($subject, $replace, $position, strlen($search)),

                $position + strlen($replace),

            ];

        }
<?php     public function __toString()

    {

        return substr_replace($this->value, '.', -$this->scale, 0);

    }

}