Finds the text between two strings within a third string.

@param $beginning
@param $end
@param $string

@return string
String containing $beginning, $end, and everything in between.
541393
private function findAllTextBetween($beginning, $end, $string) {
    $beginningPos = strpos($string, $beginning);
    $endPos = strpos($string, $end);
    if ($beginningPos === false || $endPos === false) {
      return '';
    }

    $textToDelete = substr($string, $beginningPos, ($endPos + strlen($end)) - $beginningPos);

    return $textToDelete;
  }
1151173
public static function endsWith($value, $end)
    {
        if (is_array($value)) {
            return self::last($value) == $end;
        }

        $end = "$end";

        return substr($value, -strlen($end)) === $end;
    }
1101338
public static function endsWith($string, $suffix) {
    return (mb_strrpos($string,$suffix) === mb_strlen($string) - mb_strlen($suffix));
  }
479956
private function endswith($string, $test)
    {
        $strlen = strlen($string);
        $testlen = strlen($test);
        if ($testlen > $strlen) {
            return false;
        }

        return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
    }
1209904
public function getBetweenReverse($content, $start, $end)
    {
        return $this->api->getBetweenReverse($content, $start, $end);
    }
569318
public function substringBetween($start, $end)
    {
        $ini = mb_stripos($this->str, $start, 0, $this->encoding);

        if ($ini === 0) {
            return "";
        }

        $ini += mb_strlen($start, $this->encoding);
        $len = mb_stripos($this->str, $end, $ini, $this->encoding) - $ini;

        return static::create(mb_substr($this->str, $ini, $len, $this->encoding), $this->encoding);
    }
174595
public function substring($start, $end = null)
	{
		$start = (int) $start;
		$end   = $end !== null ? (int) $end : null;

		if ($start < 0 || $start >= $this->length() || $end !== null && ($end < 0 || $end >= $this->length())) {
			throw new OutOfBoundsException();
		}

		$string = mb_substr($this->string, $start, $end !== null ? $end + 1 : $this->length(), $this->encoding);
		$stringBuilder = new StringBuilder($string);
		$stringBuilder->setEncoding($this->encoding);
		return $stringBuilder;
	}
1301782
public function source($start = null, $end = null)
    {
        $source = '';
        $start = (int) $start;
        $end = $end === null ? ($this->count() - 1) : (int) $end;
        for ($i = $start; $i <= $end; $i++) {
            $source .= $this->_data[$i][1];
        }
        return $source;
    }
718709
private function find_string($string, $start = -1, $end = -1) {
        if (($start == -1) or ($end == -1)) {
            // find_string is called with only one parameter, set start end end
            $start = 0;
            $end = $this->total;
        }
        if (abs($start - $end) <= 1) {
            // We're done, now we either found the string, or it doesn't exist
            $txt = $this->get_original_string($start);
            if ($string == $txt)
                return $start;
            else
                return -1;
        }
        else if ($start > $end) {
            // start > end -> turn around and start over
            return $this->find_string($string, $end, $start);
        }
        else {
            // Divide table in two parts
            $half = (int)(($start + $end) / 2);
            $cmp = strcmp($string, $this->get_original_string($half));
            if ($cmp == 0)
                // string is exactly in the middle => return it
                return $half;
            else if ($cmp < 0)
                // The string is in the upper half
                return $this->find_string($string, $start, $half);
            else
                // The string is in the lower half
                return $this->find_string($string, $half, $end);
        }
    }
1140281
public static function startsWith($string, $prefix)
    {
        $string = is_int($string) ? "$string" : $string;
        $prefix = is_int($prefix) ? "$prefix" : $prefix;
        return is_string($string) && is_string($prefix) && mb_substr($string, 0, mb_strlen($prefix)) === $prefix;
    }
696213
public function readBetween(int $start, int $end) : string
    {
        return implode("\n", $this->readLinesBetween($start, $end));
    }
1155103
public function replace($start, $end, $string)
	{
		$start  = (int) $start;
		$end    = (int) $end;
		$string = static::_convertString($string, $this->encoding);

		if ($start < 0 || $start >= $this->length() || $end < 0 || $end >= $this->length()) {
			throw new OutOfBoundsException();
		}

		$this->string = mb_substr(
				$this->string,
				0,
				$start,
				$this->encoding
			) .
			$string .
			mb_substr(
				$this->string,
				$end + 1,
				$this->length(),
				$this->encoding
			);
		return $this;
	}
921747
static function endsWith($string, $endsWith, $caseSensitive = true) {
		$len = self::strlen($endsWith);
		if ($caseSensitive) return self::substr($string, -1 * $len) == $endsWith;
		return self::strtolower(self::substr($string, -1 * $len)) == self::strtolower($endsWith);
	}
1057795
public static function join($strings, $separator, $start = 0, $count = -1)
    {
        $string = '';

        $end = $count == -1 ? Collection::count($strings) : $count;

        for ($i = $start; $i < $end; $i++) {
            $string .= $strings[$i].$separator;

            if ($i == ($end - 1)) {
                $string .= $separator;
            }
        }

        return $string;
    }
64224
public function substring($start, $end = null) {
		$length = $this->length();
		if ($end < 0) {
			$end = $length + $end;
		}
		$end = $end !== null ? min($end, $length) : $length;
		$start = min($start, $end);
		$end = max($start, $end);
		$end = $end - $start;

		return new Text(mb_substr($this->string, $start, $end, $this->encoding), $this->encoding);
	}
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
    }
750784
public static function endsWith($string, $end)
    {
        $l = strlen($end);
        if ($l == 0) {
            return true;
        }
        return substr($string, - $l) === $end;
    }