Check if string starts with another string

@param string $needle String to look for
@param string $haystack String to check
@param bool $caseSensitive Case sensitive check

@return bool
433026
public static function startsWith($needle, $haystack, $caseSensitive = true)
    {
        if (!self::isValid($needle)) {
            return false;
        }

        list($needle, $haystack) = self::transformCase($needle, $haystack, $caseSensitive);

        if ($needle === false) {
            return false;
        } else {
            return (self::substring($haystack, 0, self::length($needle)) === $needle);
        }
    }
658158
public function hasKey(string $needle, array $haystack) : bool
    {
        foreach ($haystack as $key => $value) {
            if ($key === $needle) {
                return true;
            }

            if (is_array($value)) {
                if ($x = $this->hasKey($needle, $value)) {
                    return $x;
                }
            }
        }

        return false;
    }
1325767
public function ends_with( $haystack, $needle ) {
		if ( '' === $haystack || '' === $needle ) {
			return false;
		}
		if ( $haystack === $needle ) {
			return true;
		}

		return substr_compare( $haystack, $needle, - strlen( $needle ) ) === 0;
	}
293614
public static function starts($haystack, $needle, $caseSensitive = false): bool
    {
        if ($caseSensitive === true) {
            return $needle === '' || mb_strpos($haystack, $needle) === 0;
        }

        return $needle === '' || mb_stripos($haystack, $needle) === 0;
    }
491966
private function startsWith($haystack,$needle,$case=true)
    {
        if($case)
            return strpos($haystack, $needle, 0) === 0;
        return stripos($haystack, $needle, 0) === 0;
    }
43731
public static function startsWith($string, $target, $caseSensitive = true)
    {
        if (!$caseSensitive) {
            $string = strtolower($string);
            $target = strtolower($target);
        }

        return strpos($string, $target) === 0;
    }
840096
public static function startsWith($haystack, $needles)
    {
        $needles = (array) $needles;

        foreach ($needles as $needle) {
            if ($needle && strpos($haystack, $needle) === 0) {
                return true;
            }
        }

        return false;
    }
1219199
private function strlikeInArray($needle, array $haystack):bool
    {
        foreach ($haystack as $one => $value) {
            if (preg_match("/$value/", $needle) === 1) {
                return (true);
            }
        }
        return (false);
    }
641779
public static function CaseInsensitiveInString ($haystack, $needle, $before_needle = FALSE, $encoding = Encoding::DEFAULT_ENCODING) {
		return mb_stristr($haystack, $needle, $before_needle, $encoding);
	}
1146110
public function arrayKeyExistsRecursiveExtended(string $needle, array $haystack): bool
    {
        $result = false;
        foreach ($haystack as $value) {
            if (true === is_array($value)) {
                $result = $this->arrayKeyExistsRecursive($needle, $value);
            }
            if (true === $result) {
                return $result;
            }
        }

        return $result;
    }
1190505
public function beginsWith(string $haystack, string $needle): bool
    {
        return (!empty($needle) && 0 === strpos($haystack, $needle));
    }
374853
public static function checkIfContainsAnyOf($haystack, $needles) {
		foreach ($needles as $needle) {
			if (self::checkIfContains($haystack, $needle)) return true;
		}
		return false;
	}
284571
public static function array_isearch($needle, array $haystack, bool $strict=true) {
		if (! \count($haystack)) {
			return false;
		}

		// Lowercase for comparison.
		ref\mb::strtolower($needle, true);
		ref\mb::strtolower($haystack, true);

		// phpcs:disable
		return array_search($needle, $haystack, $strict);
		// phpcs:enable
	}
877051
public function contains($needle, $caseSensitive = true)
    {
        $needle = $caseSensitive ? $needle : strtolower($needle);
        $string = $caseSensitive ? $this->returnValue : strtolower($this->returnValue);
        return (!(strpos($string, $needle) === false));
    }
160032
public static function stringStartsWith($haystack, $needle)
    {
        if (!is_string($haystack) || !is_string($needle)) {
            throw new \InvalidArgumentException('Not a string');
        }

        return strpos($haystack, $needle) === 0;
    }
1291942
public static function words_match($haystack, $needle)
    {
        $a_needle  = self::tokenize_string($needle, 1);
        $_haystack = join(" ", self::tokenize_string($haystack, 1));
        $valid     = strlen($_haystack) > 0;
        $hits      = 0;

        foreach ($a_needle as $w) {
            if ($valid) {
                if (stripos($_haystack, $w) !== false) {
                    $hits++;
                }
            }
            else if (stripos($haystack, $w) !== false) {
                $hits++;
            }
        }

        return $hits >= count($a_needle);
    }
336789
public static function endsWith( $haystack, $needle )
	{
		$strlen = strlen( $haystack );
		$testlen = strlen( $needle );
		if ( $testlen > $strlen ) return false;
		return substr_compare( $haystack, $needle, $strlen - $testlen, $testlen ) === 0;
	}