Checks if a string is in an array, but with wildcards.

@param String $needle
the string to search for
@param Array $haystack
the array to look in
@return boolean
14261
private function _inArray($needle, $haystack) {
		foreach ($haystack as $strand) {
			if (fnmatch($strand, $needle)) {
				return true;
			}
		}
		return false;
	}
794565
public static function exists(SimpleXMLElement $needle, SimpleXMLElement $haystack){
        foreach($haystack as $item){
            if($item->asXML() == $needle->asXML())
                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;
    }
1340777
public static function contains( $haystack, $needles )
    {
        foreach ( ( array ) $needles as $needle )
        {
            if ( '' !== $needle && FALSE !== strpos( $haystack, $needle ) )
            {
                return TRUE;
            }
        }

        return FALSE;
    }
828865
public function containsFilter($haystack, $needle)
    {
        if (empty($needle)) {
            return $haystack;
        }

        return (strpos($haystack, (string) $needle) !== false);
    }
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;
    }
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;
    }
259600
public static function subStringBeforeLast($haystack, $needle, $n = 1)
    {
        while ($n>0) {
            $haystack = substr($haystack, 0, strrpos($haystack, $needle));
            $n--;
        }
        return $haystack;
    }
1332507
public static function collectionContains($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if ($value === $needle) {
                return true;
            }
        }

        return false;
    }
454451
public static function inArray($needle, $haystack, $index)
    {
        foreach($haystack as $element)
        {
            if($element[$index] == $needle) return true;
        }
        return false;
    }
842302
private static function arraySearch(string $needle, array $haystack): string
    {
        foreach ($haystack as $key => $value) {
            if ($needle === $value || (is_array($value) && self::arraySearch($needle, $value) !== '')) {
                return $key;
            }
        }

        return '';
    }
476653
function contains($haystack, $needles)
    {
        (is_array($needles)) ?: $needles = array($needles);

        $r = false;
        foreach ($needles as $needle) {
            if ('' === $needle = (string) $needle)
                continue;

            $r |= (false !== mb_strpos($haystack, $needle));
        }

        return $r;
    }
237891
public static function assertInArray($needle, array $haystack, string $msg = '')
    {
        if ($msg === '') {
            $msg = "Expected the array to contain the element '$needle'.";
        }

        static::assertTrue(in_array($needle, $haystack, true), $msg);
    }
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;
    }
160644
private function endsWith($haystack, $needle)
    {
        $length = strlen($needle);
        if ($length === 0) {
            return true;
        }

        return substr($haystack, -$length) === $needle;
    }
811711
protected function tagSearch($needle, array $haystack)
    {
        foreach ($haystack as $actual) {
            if (0 === strcasecmp($needle, $actual)) {
                return $actual;
            }
        }

        return null;
    }
382801
public static function assertInArray($needle, array $haystack)
    {
        if (!in_array($needle, $haystack)) {
            throw new Exception("Unable to find '$needle' in array " . var_export($haystack, true));
        }
    }