Checks if a needle occurs in a haystack ;).

@param string $haystack
@param string $needle
@param string $collation
@param string $matchType

@return bool
978810
public static function textMatch($haystack, $needle, $collation, $matchType = 'contains')
    {
        switch ($collation) {
            case 'i;ascii-casemap':
                // default strtolower takes locale into consideration
                // we don't want this.
                $haystack = str_replace(range('a', 'z'), range('A', 'Z'), $haystack);
                $needle = str_replace(range('a', 'z'), range('A', 'Z'), $needle);
                break;

            case 'i;octet':
                // Do nothing
                break;

            case 'i;unicode-casemap':
                $haystack = mb_strtoupper($haystack, 'UTF-8');
                $needle = mb_strtoupper($needle, 'UTF-8');
                break;

            default:
                throw new Exception\BadRequest('Collation type: '.$collation.' is not supported');
        }

        switch ($matchType) {
            case 'contains':
                return false !== strpos($haystack, $needle);
            case 'equals':
                return $haystack === $needle;
            case 'starts-with':
                return 0 === strpos($haystack, $needle);
            case 'ends-with':
                return strrpos($haystack, $needle) === strlen($haystack) - strlen($needle);
            default:
                throw new Exception\BadRequest('Match-type: '.$matchType.' is not supported');
        }
    }
30804
public static function isNeedlesExists($haystack, $needles) {
        foreach($needles as $needle) {
            if(stripos($haystack, $needle)!==false){
                return true;
            }
        }
        return false;
    }
630345
public static function contains( $needle, $haystack, $strict = false )
    {
        foreach ( $haystack as $_index => $_value )
        {
            if ( is_string( $_value ) )
            {
                if ( 0 === strcasecmp( $needle, $_value ) )
                {
                    return true;
                }
            }
            else if ( in_array( $needle, $_value, $strict ) )
            {
                return true;
            }
        }

        return false;
    }
26891
public function exists($needle, $haystack = null)
    {
        $result = true;
        if ($haystack && $result && $haystack[0] != "00")
            $result = in_array($needle, $haystack);
        return $result;
    }
581645
public function startWithFunction($needle, $haystack = [])
    {
        if (in_array($needle, $haystack)) {
            return true;
        } else {
            foreach ($haystack as $item) {
                if (strpos($needle, $item) === 0) {
                    return true;
                }
            }
        }

        return false;
    }
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);
    }
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;
	}
569278
public static function array_ikey_exists($needle, $haystack) {
		if (! \is_array($haystack) || ! \count($haystack)) {
			return false;
		}
		$haystack = \array_keys($haystack);

		return (false !== static::array_isearch($needle, $haystack));
	}
992226
public static function containsAny(string $haystack, array $needles, bool $strict = true, string $encoding = null) : bool
    {
        return static::contains($haystack, $needles, false, $strict, $encoding);
    }
187255
protected function string_contains( $haystack, $needles ) {
		foreach ( (array) $needles as $needle ) {
			if ( '' !== $needle && mb_strpos( $haystack, $needle ) !== false ) {
				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'));
    }
374853
public static function checkIfContainsAnyOf($haystack, $needles) {
		foreach ($needles as $needle) {
			if (self::checkIfContains($haystack, $needle)) return true;
		}
		return false;
	}
76339
public static function contains($haystack, $needles)
    {
        $needles = (array) $needles;

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

        return false;
    }
702805
public static function containsAll($haystack, array $needles)
    {
        foreach ($needles as $needle) {
            if ($needle != '' && mb_strpos($haystack, $needle) === false) {
                return false;
            }
        }

        return true;
    }
394347
public static function subCount($haystack, $needle)
    {
        if (self::isMBString()) {
            return mb_substr_count($haystack, $needle, self::$encoding);
        }

        return substr_count($haystack, $needle); // @codeCoverageIgnore
    }
1052137
public function phonetic_matches($needle, array $haystack)
  {
    $needleResult = $this->phonetic_sentence($needle);
    if (\count($needleResult) === 0) {
      return array();
    }

    $isAssoc = true;
    $tmpCounter = 0;
    foreach ($haystack as $keyTmp => $valueTmp) {
      if ($keyTmp !== $tmpCounter) {
        $isAssoc = false;
        break;
      }

      $tmpCounter++;
    }

    $haystackResult = $this->phonetic_sentence($haystack);
    if (\count($haystackResult) === 0) {
      return array();
    }

    $result = array();
    foreach ($haystackResult as $haystackResultKey => $haystackResultWords) {
      foreach ($haystackResultWords as $haystackWord => $haystackCode) {

        foreach ($needleResult as $needleWord => $needleCode) {
          if ($haystackCode === $needleCode) {
            $result[$haystackResultKey][$needleWord] = $haystackWord;
          }
        }

      }
    }

    if (\count($result) > 0) {
      \uasort(
          $result, function ($a, $b) {
            if ($a == $b) {
              return 1;
            }

            return (\count($a) > \count($b)) ? -1 : 1;
          }
      );

      if ($isAssoc) {
        $resultTmp = array();
        foreach ($result as $keyTmp => $resultInner) {
          foreach ($resultInner as $resultInnerKey => $resultInnerValue) {
            $resultTmp[$resultInnerValue] = $resultInnerKey;
          }
        }

        return $resultTmp;
      }
    }

    return $result;
  }
430217
protected function contains($needle, $haystackId)
    {
        $deps = $this->getDependencies($haystackId);
        if (!is_array($deps)) {
            return false;
        }

        return in_array($needle, $deps);
    }