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

Breadcrumb

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

function ByteString::split

Overrides AbstractString::split

File

vendor/symfony/string/ByteString.php, line 364

Class

ByteString
Represents a binary-safe string of bytes.

Namespace

Symfony\Component\String

Code

public function split(string $delimiter, ?int $limit = null, ?int $flags = null) : array {
    if (1 > ($limit ??= \PHP_INT_MAX)) {
        throw new InvalidArgumentException('Split limit must be a positive integer.');
    }
    if ('' === $delimiter) {
        throw new InvalidArgumentException('Split delimiter is empty.');
    }
    if (null !== $flags) {
        return parent::split($delimiter, $limit, $flags);
    }
    $str = clone $this;
    $chunks = $this->ignoreCase ? preg_split('{' . preg_quote($delimiter) . '}iD', $this->string, $limit) : explode($delimiter, $this->string, $limit);
    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