get_string_between
@param string $string
@param string $start
@param string $end
@return string
@throws \Exception
961935
static function get_string_between($string, $start, $end){
        try {
            $string = " ".$string;
            $ini = strpos($string,$start);
            if ($ini == 0) return "Start non trouve";
            $ini += strlen($start);
            $len = strpos($string,$end,$ini) - $ini;
            return substr($string,$ini,$len);
        } catch (Exception $e) {
            $msg = $e->getMessage();
            Throw new \Exception('Erreur dans '.__CLASS__.' : '.$msg);
            return null;
        }
    }
335492
public static function sub(string $string, int $start, ?int $length = null, string $encode = 'UTF-8'): ?string
    {
        return mb_substr($string, $start, $length, $encode);
    }
919776
static function Part($string, $start, $length = null)
    {
        self::InitEncoding();
        if ($length !== null)
            return mb_substr($string, $start, $length);

        return mb_substr($string, $start);
    }
1158411
public static function substring($string, $length = 50, $start = 0, $ellipsis = true)
    {
        $newString = trim(mb_substr($string, $start, $length, 'UTF-8'));
        if (mb_strlen($newString) < mb_strlen($string) && $ellipsis) {
            return $newString.'...';
        } //&hellip;

        return $newString;
    }
601437
public function getBetween($content, $start, $end = null)
    {
        return $this->api->getBetween($content, $start, $end);
    }
915617
public String substringBetween(String string, String begin, String end, boolean includeBoundaries) {
		if (string == null || begin == null || end == null) {
			return null;
		}
		int startPos = string.indexOf(begin);
		if (startPos != -1) {
			if (includeBoundaries)
				startPos = startPos - begin.length();
			int endPos = string.lastIndexOf(end);
			if (endPos != -1) {
				if (includeBoundaries)
					endPos = endPos + end.length();
				return string.substring(startPos + begin.length(), endPos);
			}
		}
		return null;
	}
1288238
public static function findCharPosition($string, $char, $startAt = 0)
    {
        $position = strpos($string, $char, $startAt);

        return ($position !== false) ? $position + 1 : null;
    }
720553
public static function startsWith($string, $beginning)
    {
        if (!empty($string) && !empty($beginning)) {
            if (1 === strlen($beginning) && !self::isLetterOrDigit($beginning)) {
                $beginning = '\\' . $beginning;
            }

            $pattern = sprintf('|^%s|', $beginning);

            return (bool)preg_match($pattern, $string);
        }

        return false;
    }
1009690
public static function between(
        $string,
        $start,
        $end,
        $offset = 0,
        $encoding = null
    ) {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        $startIndex = Mbstring::strpos($string, $start, $offset, $encoding);

        if ($startIndex === false) {
            return '';
        }

        $substrIndex = $startIndex + Mbstring::strlen($start, $encoding);

        $endIndex = Mbstring::strpos($string, $end, $substrIndex, $encoding);

        if ($endIndex === false) {
            return '';
        }

        return Mbstring::substr($string, $substrIndex, $endIndex - $substrIndex);
    }
580615
public function between(\DateTime $start, \DateTime $end)
    {
        // Comparing DateTime also looks at the time. So we need to make sure the time is 0,
        // but don't modify the original referenced DateTime parameters
        $start = clone $start;
        $end = clone $end;
        $start->setTime(0, 0, 0);
        $end->setTime(0, 0, 0);

        $startyear = (int) $start->format("Y");
        $endyear   = (int) $end->format("Y");
        $holidays  = array();
        for ($y = $startyear; $y <= $endyear; $y++) {
            $holidays = array_merge($holidays, $this->getHolidays($y));
        }

        return array_filter($holidays,
            function(\DateTime $dt) use ($start, $end) {
                return $dt >= $start && $dt <= $end;
            });
    }
1097681
public static function substr($string, $start, $length = null)
    {
        return mb_substr($string, $start, $length, self::ENCODING);
    }
373530
private function stringStartsWith(string $string, string $prefix): bool
    {
        return substr($string, 0, strlen($prefix)) === $prefix;
    }
1153358
public static function _randCharacter($start = 32, $end = 126) {
        $amountToAdd = $end - $start;
        return chr($start + self::_getRand(0, $amountToAdd));
    }
94882
public function whereBetween($field, $start, $end)
    {
        $this->prepareWhereBetween($field, $start, $end, 'between');

        return $this;
    }
1273880
protected static function intersect($string, $subString, $start)
    {
        $cut = str_split(substr($string, $start, strlen($subString)));
        $comp = str_split($subString);
        foreach ($cut as $i => $c) {
            if ($comp[$i] === $c) {
                $intersect[] = $c;
            } else {
                break; // Stop loop since intersection ends.
            }
        }
        if (!empty($intersect)) {
            return implode('', $intersect);
        }

        return '';
    }
875256
public function truncate($string, $endlength="30", $end="...")
        {
            $strlen = strlen($string);

            if ($strlen > $endlength) {
                $trim = $endlength - $strlen;
                $string = substr($string, 0, $trim);
                $string .= $end;
            }

            return $string;
        }
108480
public static function hideString($string, $start, $end, $replace = "*")
    {
        $length = strlen($string);
        $result = '';

        if ($start >= $length) {
            return $result;
        }
        if ($end <= $start) {
            return $result;
        }

        for ($i = 0; $i < $length; $i++) {
            $result .= $i >= $start && $i <= $end ? $replace : $string[$i];
        }
        return $result;
    }