查找字符串第一次出现的位置
@param string $haystack
@param string $needle
@param int $start = 0 开始查找的位置
@param string $encoding = 'UTF-8'
@throws \Exception
@return string
434461
public static function strpos($haystack, $needle, $start = 0, $encoding = 'UTF-8') {
	    if(function_exists('iconv_substr')) {
	        return iconv_strpos($haystack, $needle, $start, $encoding);
	    } elseif(function_exists('mb_substr')) {
	        return mb_strpos($haystack, $needle, $start, $encoding);
	    }
	    throw new \Exception('请先安装PHP iconv或mb_string扩展');
	}
182711
public static function strpos(string $haystack, string $needle, int $offset=0) {
		if (\function_exists('mb_strpos')) {
			return \mb_strpos($haystack, $needle, $offset, 'UTF-8');
		}

		return \strpos($haystack, $needle, $offset);
	}
426322
public static function startsWith($haystack, $needle, $ignoreCase = false)
    {
        if ($ignoreCase) {
            return stripos($haystack, $needle) === 0;
        } else {
            return strpos($haystack, $needle) === 0;
        }
    }
31724
public static function hasBeginning(string $needle, string $haystack): bool
    {
        return $needle === '' || strpos($haystack, $needle) === 0;
    }
1081671
public static function replace($needle, $replacement, ?string $haystack): ?string
    {
        if ($haystack === null) {
            return null;
        }

        return str_replace($needle, $replacement, $haystack);
    }
199271
public function endsWith(string $haystack, string $needle): bool
    {
        $escaped = preg_quote($needle);

        return (bool) preg_match("/$escaped$/", $haystack);
    }
404310
public static function substr_count(string $haystack, string $needle) {
		if (\function_exists('mb_substr_count')) {
			return \mb_substr_count($haystack, $needle, 'UTF-8');
		}
		else {
			return \substr_count($haystack, $needle);
		}
	}
263334
public static function Position ($haystack, $needle, $offset = 0, $encoding = Encoding::DEFAULT_ENCODING) {
		return mb_strpos($haystack, $needle, $offset, $encoding);
	}
441400
public static function startsWith($haystack, $needle)
    {
        $length = strlen($needle);

        return substr($haystack, 0, $length) === $needle;
    }
1161222
protected function endsWith($haystack, $needle)
    {
        $length = \mb_strlen($needle);

        return $length === 0 || (\mb_substr($haystack, -$length) === $needle);
    }
98081
public static function strpos($haystack, $needle, $offset = 0)
    {
        return mb_strpos($haystack, $needle, $offset, self::ENCODING);
    }
516855
public static function endsWith($haystack, $needle)
    {
        if (strlen($haystack) < strlen($needle)) {
            return false;
        }
        $end = substr($haystack, strlen($haystack) - strlen($needle), strlen($needle));

        return $needle === "" || $needle === $end;
    }
417654
public static function stringEndsWith($haystack, $needle)
    {
        if (substr($haystack, - strlen($needle)) === $needle) {
            return true;
        }

        return false;
    }
742125
public static function stringBeginsWith($haystack, $needle)
    {
        if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
            return true;
        }

        return false;
    }
290754
public static function startsWith( $haystack, $needles )
	{
		if ( is_array( $haystack ) )
			throw new FrameworkException( "\$haystack must be a string!" );

		foreach ( (array) $needles as $needle )
			if ( $needle != '' && mb_strpos( $haystack, $needle ) === 0 )
				return true;

		return false;
	}
1013213
protected function stringHasStatement( $haystack, $needle ) {
		$pattern = '~^\s*(' . preg_quote( $needle, '~' ) . ')\s*$~m';
		return (bool) preg_match( $pattern, $haystack );
	}
819572
public static function inArrayCaseInsensitive($needle, $haystack)
    {
        if (!$haystack || !is_array($haystack)) {
            return false;
        }
        $lcase = array();
        foreach ($haystack as $key => $val) {
            $lcase[$key] = strtolower($val);
        }
        return in_array(strtolower($needle), $lcase);
    }