Get a value from a nested array based on a separated key
@param  string $key
@param  array  $array
@return mixed
775153
protected function getValue($key, array $array = array())
    {
        $keys = $this->parseKey($key);

        while (count($keys) > 0 and !is_null($array)) {
            $key = array_shift($keys);
            $array = isset($array[$key]) ? $array[$key] : null;
        }

        return $array;
    }
1172623
public static function drop(array &$array, $key)
    {
        $keys = explode('.', $key);
        $last = array_pop($keys);
        foreach($keys as $key) {
            if(!isset($array[$key])) {
                return false;
            }
            $array = &$array[$key];
        }

        if(isset($array[$last])) {
            unset($array[$last]);
            return true;
        }

        return false;
    }
479408
public static function has(array $array, $key)
    {
        if (array_key_exists($key, $array)) {
            return true;
        }

        if (strpos($key, '.') === false) {
            return false;
        }

        foreach (explode('.', $key) as $segment) {
            if (is_array($array) && array_key_exists($segment, $array)) {
                $array = $array[$segment];
            } else {
                return false;
            }
        }

        return true;
    }
1181280
public static function get($array, $key, $default = null) {
        $keys = explode(".", $key);
        $level = &$array;
        $length = count($keys);
        foreach($keys as $index => $key) {
            if (!is_array($level)) {
              return null;
            }

            if(array_key_exists($key, $level)) {
                if($index == $length-1) {
                    return $level[$key];
                } else {
                    $level = &$level[$key];
                }
            } else {
                return $default;
            }
        }
        return $default;
    }
745007
protected function getAnyKey(array $keys)
    {
        foreach($keys as $key)
        {
            $value = $this->getValue($key);

            if(!is_null($value))
            {
                return $value;
            }
        }
    }
11225
public function arrayKey(array $array, $key = 'key'): array
    {
        $out = [];

        foreach ($array as $id => $item) {
            if (isset($item[$key])) {
                $out[$item[$key]] =  $item;
            } else {
                $out[$id] =  $item;
            }
        }

        return $out;
    }
1086027
public function get($key)
    {
        $this->load();
        $value = NestedArrayUtil::getNestedArrayValue($this->state, explode('.', $key), $exists);

        return $exists ? $value : false;
    }
1051906
public static function delete(&$array, $key)
	{
		if (is_null($key))
		{
			return false;
		}

		if (is_array($key))
		{
			$return = array();
			foreach ($key as $k)
			{
				$return[$k] = static::delete($array, $k);
			}
			return $return;
		}

		$key_parts = explode('.', $key);

		if (! is_array($array) or ! array_key_exists($key_parts[0], $array))
		{
			return false;
		}

		$this_key = array_shift($key_parts);

		if (! empty($key_parts))
		{
			$key = implode('.', $key_parts);
			return static::delete($array[$this_key], $key);
		}
		else
		{
			unset($array[$this_key]);
		}

		return true;
	}
741958
public static function get($array, $key, $default = null)
    {
        return is_array($key)
            ? static::getArray($array, $key, $default)
            : parent::get($array, $key, $default);
    }
920507
public static function get(array $array, $keyPath)
    {
        self::checkKeyPathIsValidAndNonEmpty($keyPath);
        $keys = self::explodeKeys(strval($keyPath));

        $nextValue = null;
        while ($keys !== array()) {
            $key = array_shift($keys);

            if (!array_key_exists($key, $array)) {
                throw new KeyNotFound($keyPath);
            }
            $nextValue = $array[$key];
            if (!is_array($nextValue)) {
                break;
            }
            $array = $nextValue;
        }

        if ($keys === array()) {
            return $nextValue;
        }

        throw new KeyNotFound($keyPath);
    }
1109011
public static function getValueOfArray(array $array, $key, $default = null)
    {
        if (null === $key) {
            return $array;
        }

        if (\array_key_exists($key, $array)) {
            return $array[$key];
        }

        if (!\strpos($key, '.')) {
            return $default;
        }

        foreach (\explode('.', $key) as $segment) {
            if (\is_array($array) && \array_key_exists($segment, $array)) {
                $array = $array[$segment];
            } else {
                return $default;
            }
        }

        return $array;
    }
890545
public static function assignByKey($array, $key, $group = false)
    {

        if (empty($array)) return $array;

        $res = array();
        foreach ($array as $subthing) {
            $idx = null;
            if (is_object($subthing) && property_exists($subthing, $key)) {
                $idx = $subthing->$key;
            } elseif (is_array($subthing) && isset($subthing[$key])) {
                $idx = $subthing[$key];
            }
            if ($idx !== null) {
                if (!$group) {
                    $res[$idx] = $subthing;
                } else {
                    if (!isset($res[$idx])) $res[$idx] = array();
                    $res[$idx][] = $subthing;
                }
            }
        }

        return $res;
    }
943552
public static function fetch( $array, $key )
    {
        $result = [ ];

        foreach ( explode( '.', $key ) as $segment )
        {
            foreach ( $array as $value )
            {
                $value = ( array ) $value;

                $result[ ] = $value[ $segment ];
            }

            $array = array_values( $result );
        }

        return array_values( $result );
    }
858813
public static function remove(array $array, string $key): array
    {
        // Extract key/path.
        $keyLast = Str::last($key, '.');
        $key = Str::removeLast($key, '.');

        // If found, remove element.
        $arrayElement = &self::dataByPath($array, $key, false, 'not.found');
        if ($arrayElement !== 'not.found') {
            if (array_key_exists($keyLast, $arrayElement)) {
                unset($arrayElement[$keyLast]);
            }
        }

        return $array;
    }
18642
public static function pluck(array $array, $key)
    {
        return array_map(
            function ($item) use ($key) {
                return is_object($item) ? $item->$key : $item[$key];
            },
            $array
        );
    }
461054
public static function isKeyWithElements($array, $key)
    {
        if (false === is_array($array) || false === isset($array[$key])) {
            return false;
        }

        if (false === is_array($array[$key])) {
            return false;
        }

        if (0 === count($array[$key])) {
            return false;
        }

        return true;
    }
243573
public function getArray($key)
    {
        try {
            $result = $this->get(self::DATA_ARRAY, $key);
            if (!settype($result, 'array')) {
                return null;
            }
        } catch (\Exception $e) {
            return null;
        }
        return $result;
    }