Get a value from an array. Return <code>null</code> if the key does not exist in the array.

@param integer|string $needle
@param mixed $haystack
@return mixed
968707
private function getValueFromArray($needle, $haystack)
    {
        if (!is_array($haystack) || !isset($haystack[$needle])) {
            return null;
        }

        return $haystack[$needle];
    }
870780
public static function recursivelyGetValue($needleKey, array &$haystack)
    {
        $result = null;
        foreach ($haystack as $key => &$value) {
            if (isset($haystack[$needleKey])) {
                $result = $haystack[$needleKey];
            } elseif (is_array($value)) {
                $result = self::recursivelyGetValue($needleKey, $value);
            }
        }
        return $result;
    }
1332507
public static function collectionContains($needle, $haystack)
    {
        foreach ($haystack as $value) {
            if ($value === $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 '';
    }
1112711
public function arrayMultiSearch($needle, $haystack) {
        foreach ($haystack as $key => $data) {
            if (in_array($needle, $data)) {
                return $key;
            }
        }
        return false;
    }
284571
public static function array_isearch($needle, array $haystack, bool $strict=true) {
		if (! \count($haystack)) {
			return false;
		}

		// Lowercase for comparison.
		ref\mb::strtolower($needle, true);
		ref\mb::strtolower($haystack, true);

		// phpcs:disable
		return array_search($needle, $haystack, $strict);
		// phpcs:enable
	}
1305625
public static function endsWith($haystack, $needle)
    {
        return $needle == substr($haystack, strlen($haystack) - strlen($needle));
    }
311057
public static function recursiveArraySearch($needleKey, $needleValue,
                                                array $haystack)
    {
        foreach ($haystack as $key => $value) {
            $currentKey = $key;

            if (($currentKey == $needleKey && ($needleValue === null || $needleValue
                == $value)) || ( is_array($value) && self::recursiveArraySearch($needleKey,
                    $needleValue, $value) !== false)) {
                return $currentKey;
            }
        }
        return null;
    }
991230
public function match($needle, $haystack)
    {
        $len = strlen($needle);

        /** @noinspection SubStrUsedAsStrPosInspection */
        return $len === 0 || substr($haystack, 0, $len) === $needle;
    }
1360988
public static function unsetInArrayByValue($needle, array $haystack, $reIndex = true)
    {
        $doReindex = false;

        foreach($haystack as $key => $value) {
            if (is_array($value)) {
                $haystack[$key] = static::unsetInArrayByValue($needle, $value);
            } else if ($needle === $value) {

                unset($haystack[$key]);

                if ($reIndex) {
                    $doReindex = true;
                }
            }
        }

        if ($doReindex) {
            $haystack = array_values($haystack);
        }

        return $haystack;
    }
806508
protected function arraySearch($needle, $haystack, $property)
    {
        return array_search($needle, array_map(function ($value) use ($property) {
            return \is_object($value) ? $value->$property : $value[$property];
        }, $haystack), true);
    }
583910
public static function pos($haystack, $needle, $offset = 0)
    {
        if (self::isMBString()) {
            return mb_strpos($haystack, $needle, $offset, self::$encoding);
        }

        return strpos($haystack, $needle, $offset); // @codeCoverageIgnore
    }
1344326
private function index_of($haystack, $needle, $offset = 0)
    {
        $index = strpos($haystack, $needle, $offset);

        return ($index !== FALSE) ? $index : -1;
    }
758926
private function arraySearch( $needle, array $haystack ) {
		foreach ( $haystack as $valueOffset => $thing ) {
			if ( $this->valueComparer->valuesAreEqual( $needle, $thing ) ) {
				return $valueOffset;
			}
		}

		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;
    }
1068980
public function strpos($haystack, $needle, $offset = 0)
    {
        return mb_strpos($haystack, $needle, $offset, $this->getEncoding());
    }
1219199
private function strlikeInArray($needle, array $haystack):bool
    {
        foreach ($haystack as $one => $value) {
            if (preg_match("/$value/", $needle) === 1) {
                return (true);
            }
        }
        return (false);
    }