Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. CodePointString.php

function CodePointString::splice

Overrides AbstractString::splice

File

vendor/symfony/string/CodePointString.php, line 197

Class

CodePointString
Represents a string of Unicode code points encoded as UTF-8.

Namespace

Symfony\Component\String

Code

public function splice(string $replacement, int $start = 0, ?int $length = null) : static {
    if (!preg_match('//u', $replacement)) {
        throw new InvalidArgumentException('Invalid UTF-8 string.');
    }
    $str = clone $this;
    $start = $start ? \strlen(mb_substr($this->string, 0, $start, 'UTF-8')) : 0;
    $length = $length ? \strlen(mb_substr($this->string, $start, $length, 'UTF-8')) : $length;
    $str->string = substr_replace($this->string, $replacement, $start, $length ?? \PHP_INT_MAX);
    return $str;
}
RSS feed
Powered by Drupal