Slices a piece of the string from a given offset with a specified length.
If no length is given, the String is sliced to its maximum length.

@see #substring
@param int $offset
@param int $length
@return Text
760386
public function slice($offset, $length = null) {
		$offset = $this->prepareOffset($offset);
		$length = $this->prepareLength($offset, $length);

		if ($length === 0) {
			return new Text('', $this->encoding);
		}

		return new Text(mb_substr($this->string, $offset, $length, $this->encoding), $this->encoding);
	}
914510
public function getSlice($offset, $length)
    {
        $childrenTags = $this->tagsService->loadTagChildren($this->tag, $offset, $length);

        if (!isset($this->nbResults)) {
            $this->nbResults = $this->tagsService->getTagChildrenCount($this->tag);
        }

        return $childrenTags;
    }
980859
public function slice($offset, $length = null)
    {
        return new static(array_slice($this->objects, $offset, $length, true));
    }
418292
public function substr(int $offset, int $length = -1, bool $remove = false) {
        if ($this->swoole_buffer) {
            return $this->swoole_buffer->substr($offset, $length, $remove);
        }
        return null;
    }
366505
public function getSlice($offset, $length): array
    {
        $query = clone $this->query;
        $query->offset = $offset;
        $query->limit = $length;
        $query->performCount = false;

        $trashItems = $this->trashService->findTrashItems($query);

        if (null === $this->nbResults && null !== $trashItems->count) {
            $this->nbResults = $trashItems->count;
        }

        return $trashItems->items;
    }
47414
public static function getSlice($string, $offset, $length = null)
    {
        if (self::checkMB()) {
            return mb_substr($string, $offset, $length, '8bit');
        }
        if ($length === null) {
            $length = strlen($string);
        }
        return substr($string, $offset, $length);
    }
1170077
protected function readString($fr,$length,$offset=null)
	{
		if($offset!==null)
			fseek($fr,$offset);
		return $this->readByte($fr,$length);
	}
263908
public function read($length = null) {
		if (isset($length)) {
			return substr($this->str, 0, $length);
		}
		return $this->str;	
	}
1128964
public static function substr($string, $from, $length = null)
    {
        if (false === $encoding = mb_detect_encoding($string, null, true)) {
            return substr($string, $from, $length);
        }

        return mb_substr($string, $from, $length, $encoding);
    }
88115
public function substring($start, $length = null)
    {

        if ($length == null) {
            $substring = substr($this->value, $start);
        } else {
            $substring = substr($this->value, $start, $length);
        }

        $this->value = $substring;

        return $this;


    }
965372
protected function substrCount($haystack, $needle, $offset, $length)
    {
        static $oldVersion;
        if ($oldVersion === null) {
            $oldVersion = version_compare(PHP_VERSION, '5.1', '<');
        }
        if ($oldVersion) {
            $haystack = substr($haystack, $offset, $length);
            return substr_count($haystack, $needle);
        } else {
            return substr_count($haystack, $needle, $offset, $length);
        }
    }
413751
public static function sub($string, $start, $length = 0)
    {
        if (self::isMBString()) {
            if (0 === $length) {
                $length = self::len($string);
            }

            return mb_substr($string, $start, $length, self::$encoding);
        }

        return substr($string, $start, $length); // @codeCoverageIgnore
    }
221031
public function slice($offset=0, $length=null)
    {
        $result = $this->createChildInstance();
        $result->nodes = \array_slice($this->nodes, $offset, $length);
        $result->length = \count($result->nodes);
        return $result;
    }
514910
public static function str_split($s, $length = null)
	{
		if (! ReflectionTypeHint::isValid()) return false;
		if (is_null($s)) return $s;

		$length = ($length === null) ? 1 : intval($length);
		if ($length < 1) return false;
		#there are limits in regexp for {min,max}!
		if (preg_match_all('~.~suSX', $s, $m) === false) return false;
		if (function_exists('preg_last_error') && preg_last_error() !== PREG_NO_ERROR) return false;
		if ($length === 1) $a = $m[0];
		else
		{
			$a = array();
			for ($i = 0, $c = count($m[0]); $i < $c; $i += $length) $a[] = implode('', array_slice($m[0], $i, $length));
		}
		return $a;
	}
263493
public function read($offset, $length = 1)
    {
        $ret = '';
        $segno = floor($offset / $this->segsize);
        $sOffset = $offset % $this->segsize;
        while (true) {
            if (!isset($this->segments[$segno])) {
                if (!$this->open($segno)) {
                    goto ret;
                }
            }

            $ret .= shmop_read($this->segments[$segno], $sOffset, min($length - mb_orig_strlen($ret), $this->segsize));

            if (mb_orig_strlen($ret) >= $length) {
                goto ret;
            }

            ++$segno;

            $sOffset = 0;
        }
        ret:

        return $ret === '' ? false : $ret;
    }
135227
public function offsetAfter ($offset) {
		return ($offset < $this->_length) ? static::Substring($this->_string, $offset) : static::EMPTY_CHAR;
	}
797437
public function slice($from, $length = null) {
        if ($length === null) {
            return substr($this->buffer, $from);
        }

        return substr($this->buffer, $from, $length);
    }