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\GraphemeCode
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));
}