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

Breadcrumb

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

function Grapheme::grapheme_substr

1 call to Grapheme::grapheme_substr()
Grapheme::grapheme_position in vendor/symfony/polyfill-intl-grapheme/Grapheme.php

File

vendor/symfony/polyfill-intl-grapheme/Grapheme.php, line 121

Class

Grapheme
Partial intl implementation in pure PHP.

Namespace

Symfony\Polyfill\Intl\Grapheme

Code

public static function grapheme_substr($s, $start, $len = null) {
    if (null === $len) {
        $len = 2147483647;
    }
    preg_match_all('/' . SYMFONY_GRAPHEME_CLUSTER_RX . '/u', $s, $s);
    $slen = \count($s[0]);
    $start = (int) $start;
    if (0 > $start) {
        $start += $slen;
    }
    if (0 > $start) {
        if (\PHP_VERSION_ID < 80000) {
            return false;
        }
        $start = 0;
    }
    if ($start >= $slen) {
        return \PHP_VERSION_ID >= 80000 ? '' : false;
    }
    $rem = $slen - $start;
    if (0 > $len) {
        $len += $rem;
    }
    if (0 === $len) {
        return '';
    }
    if (0 > $len) {
        return \PHP_VERSION_ID >= 80000 ? '' : false;
    }
    if ($len > $rem) {
        $len = $rem;
    }
    return implode('', \array_slice($s[0], $start, $len));
}

API Navigation

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