Wrapper For strpos()

@param string $haystack Haystack.
@param string $needle Needle.
@param int $offset Offset.
@return int|bool First occurrence or false.
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);
	}
697528
public static function startsWith($haystack, $needle, $case_sensitive = true)
    {
        $status = false;

        $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';

        foreach ((array)$needle as $each_needle) {
            $status = $each_needle === '' || $compare_func($haystack, $each_needle) === 0;
            if ($status) {
                break;
            }
        }

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

        return false;
    }
454947
public static function starts_with( $haystack, $needles ) {
		foreach ( (array) $needles as $needle ) {
			if ( '' !== $needle && 0 === strpos( $haystack, $needle ) ) {
				return true;
			}
		}

		return false;
	}
749658
public static function recursiveArraySearch($needle, $haystack)
    {
        foreach ($haystack as $key => $value) {
            $current_key = $key;
            if ($needle === $value or (is_array($value) && self::recursiveArraySearch($needle, $value) !== false)) {
                return $current_key;
            }
        }
        return false;
    }
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);
    }
1051470
public static function indexOf(string $haystack, string $needle, int $nth = 1): ?int
    {
        $pos = static::pos($haystack, $needle, $nth);

        return $pos === null
            ? null
            : \mb_strlen(\substr($haystack, 0, $pos));
    }
1305279
public static function getStartsWith($haystack, $needles)
    {
        foreach ((array) $needles as $needle) {
            if ($needle != '' && strpos($haystack, $needle) === 0) {
                return $needle;
            }
        }

        return false;
    }
680531
public static function startsWith(string $haystack, string $needle) : bool
    {
        return !strncmp($haystack, $needle, strlen($needle));
    }
649501
public static function startsWith($haystack, $needle)
    {
        if (strlen($haystack) < strlen($needle)) {
            return false;
        }
        $start = substr($haystack, 0, strlen($needle));

        return $needle === "" || $needle === $start;
    }
1109425
protected function strlikeInArray($needle, array $haystack)
    {
        if (isset($haystack["options"])) {
            $haystack = $haystack["options"];
        }
        foreach ($haystack as $value) {
            if (strpos($value, $needle) !== false) {
                return ($value);
            }
        }
        return (null);
    }
981782
public static function getNeedlePositions($haystack, $needle)
    {
        $start = 0;
        $result = array();
        $needleLength = strlen($needle);

        while (($pos = strpos($haystack, $needle, $start)) !== false) {
            $start = $pos + 1;

            // Calculate starting and ending positions
            $startPos = $pos;
            $endPos = $pos + $needleLength;

            // Save them
            $result[$startPos] = $endPos;
        }

        return $result;
    }
568066
public static function iPos($haystack, $needle, $offset = 0)
    {
        if (self::isMBString()) {
            return mb_stripos($haystack, $needle, $offset, self::$encoding);
        }

        return stripos($haystack, $needle, $offset); // @codeCoverageIgnore
    }
758926
private function arraySearch( $needle, array $haystack ) {
		foreach ( $haystack as $valueOffset => $thing ) {
			if ( $this->valueComparer->valuesAreEqual( $needle, $thing ) ) {
				return $valueOffset;
			}
		}

		return false;
	}
454451
public static function inArray($needle, $haystack, $index)
    {
        foreach($haystack as $element)
        {
            if($element[$index] == $needle) return true;
        }
        return false;
    }
568917
public static function startWith(string $haystack, string $needle): bool
    {
        return ($needle === mb_substr($haystack, 0, mb_strlen($needle, 'UTF-8'), 'UTF-8'));
    }
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扩展');
	}