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

Breadcrumb

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

function AbstractString::split

Return value

static[]

7 calls to AbstractString::split()
AbstractString::wordwrap in vendor/symfony/string/AbstractString.php
ByteString::split in vendor/symfony/string/ByteString.php
ByteString::split in vendor/symfony/string/ByteString.php
CodePointString::split in vendor/symfony/string/CodePointString.php
CodePointString::split in vendor/symfony/string/CodePointString.php

... See full list

3 methods override AbstractString::split()
ByteString::split in vendor/symfony/string/ByteString.php
CodePointString::split in vendor/symfony/string/CodePointString.php
UnicodeString::split in vendor/symfony/string/UnicodeString.php

File

vendor/symfony/string/AbstractString.php, line 446

Class

AbstractString
Represents a string of abstract characters.

Namespace

Symfony\Component\String

Code

public function split(string $delimiter, ?int $limit = null, ?int $flags = null) : array {
    if (null === $flags) {
        throw new \TypeError('Split behavior when $flags is null must be implemented by child classes.');
    }
    if ($this->ignoreCase) {
        $delimiter .= 'i';
    }
    set_error_handler(static fn($t, $m) => throw new InvalidArgumentException($m));
    try {
        if (false === ($chunks = preg_split($delimiter, $this->string, $limit, $flags))) {
            throw new RuntimeException('Splitting failed with error: ' . preg_last_error_msg());
        }
    } finally {
        restore_error_handler();
    }
    $str = clone $this;
    if (self::PREG_SPLIT_OFFSET_CAPTURE & $flags) {
        foreach ($chunks as &$chunk) {
            $str->string = $chunk[0];
            $chunk[0] = clone $str;
        }
    }
    else {
        foreach ($chunks as &$chunk) {
            $str->string = $chunk;
            $chunk = clone $str;
        }
    }
    return $chunks;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal