PHP 5.0.x compatible substr_count that implements offset and length
@param string $haystack
@param string $needle
@param int $offset
@param int $length
@return int
965372
protected function substrCount($haystack, $needle, $offset, $length)
    {
        static $oldVersion;
        if ($oldVersion === null) {
            $oldVersion = version_compare(PHP_VERSION, '5.1', '<');
        }
        if ($oldVersion) {
            $haystack = substr($haystack, $offset, $length);
            return substr_count($haystack, $needle);
        } else {
            return substr_count($haystack, $needle, $offset, $length);
        }
    }
1013213
protected function stringHasStatement( $haystack, $needle ) {
		$pattern = '~^\s*(' . preg_quote( $needle, '~' ) . ')\s*$~m';
		return (bool) preg_match( $pattern, $haystack );
	}
1239455
public function in_multiarray($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if (is_array($value)) {
                if ($this->in_multiarray($needle, $value)) {
                    return true;
                }
            } else {
                if ($value == $needle) {
                    return true;
                }
            }
        }
        return false;
    }
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;
    }
927494
public static function contains(string $haystack, string $needle): bool
    {
        return mb_strpos($haystack, $needle, 0, 'UTF-8') !== false;
    }
913952
public static function endsWith(
        string $haystack,
        string $needle,
        $caseSensitive = true
    ) : bool {
        $needleLength = strlen($needle);
        $cmp = substr_compare(
            $haystack,
            $needle,
            -($needleLength),
            $needleLength,
            !$caseSensitive
        );

        return $cmp === 0;
    }
564123
public function strpos($haystack, $needle)
    {
        $hstck = '' . $haystack;
        $ndl = '' . $needle;
        if ($hstck === '' || $ndl === '') {
            return false;
        }
        if (static::$nativeSupport['mbstring']) {
            return mb_strpos($hstck, $ndl);
        }

        $pos = strpos($hstck, $ndl);
        if (!$pos) {
            return $pos;
        }
        return count(
            preg_split('//u', substr($hstck, 0, $pos), null, PREG_SPLIT_NO_EMPTY)
        );
    }
1109289
public static function substrToString($haystack, $needle, $case_sensitive = true)
    {
        $compare_func = $case_sensitive ? 'mb_strpos' : 'mb_stripos';

        if (static::contains($haystack, $needle, $case_sensitive)) {
            return mb_substr($haystack, 0, $compare_func($haystack, $needle, $case_sensitive));
        }

        return $haystack;
    }
1215036
protected function in_array($needle, $haystack)
    {
        return count(array_filter($haystack, function ($hay) use ($needle) {
            return $hay === $needle;
        })) > 0;
    }
229443
public static function StartsWith($haystack, $needle)
    {
        $length = static::Length($needle);

        return substr($haystack, 0, $length) === $needle;
    }
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
    }
1161222
protected function endsWith($haystack, $needle)
    {
        $length = \mb_strlen($needle);

        return $length === 0 || (\mb_substr($haystack, -$length) === $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;
    }
742125
public static function stringBeginsWith($haystack, $needle)
    {
        if (!empty($needle) && strncmp($haystack, $needle, strlen($needle)) === 0) {
            return true;
        }

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

        return false;
    }
580397
public static function search(array $haystack, $needle)
    {
        foreach ($haystack as $key => $value) {
            if (is_array($value)) {
                $target = self::search($value, $needle); 
            } else {
                $target = '';
            }

            if ($needle === $value || ($target != false && $target != null)) {
                if ($target == null) {
                    return array($key);
                }
                return array_merge(array($key), $target);
            }
        }

        return false;
    }
1285782
public static function startsWith($haystack, $needle) {
		if($needle === null && $haystack === null)
			return false;
		if($needle === null && $haystack !== null)
			return true;
		return $needle === "" || strrpos($haystack, $needle, -strlen($haystack)) !== false;
	}