Returns all values of given key.
It may be useful when you want to retrieve all values of one column.

@param array  $array The array which should contain values of the key
@param string $key   The key
@return null|array
165104
public static function getAllValuesOfKey(array $array, $key)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $values = [];

        foreach ($array as $index => $value) {
            if ($index === $key) {
                $values[] = $value;

                continue;
            }

            if (is_array($value)) {
                $recursiveValues = self::getAllValuesOfKey($value, $key);

                if (!empty($recursiveValues)) {
                    $merged = array_merge($values, $recursiveValues);
                    $values = $merged;
                }
            }
        }

        return $values;
    }
966751
protected function getValuesFromKeyMap( $key )
    {
        if ( empty( $key ) || empty( $this->keyMap[$key] ) )
        {
            return null;
        }

        return $this->keyMap[$key];
    }
172276
protected function find($array, $key)
    {
        if (empty($key) && !is_numeric($key) || empty($array) || !is_array($array)) {
            return [false, null];
        }

        $partsOfKey = explode('.', $key);
        $variants = [];
        $parts = [];

        do {
            $partial = implode('.', $partsOfKey);

            if (array_key_exists($partial, $array)) {
                if (!count($parts)) {
                    return [true, $array[$partial]];
                }

                $variants[implode('.', $parts)] = $array[$partial];
            }

            array_unshift($parts, array_pop($partsOfKey));
        } while (count($partsOfKey));

        foreach ($variants as $path => $branch) {
            list($has, $value) = $this->find($branch, $path);

            if ($has) {
                return [true, $value];
            }
        }

        return [false, null];
    }
1056777
public static function get($array, string $key, $default = null)
    {
        if (! Assert::array($array)) {
            return $default;
        }

        $key = trim($key);

        if ($key === '') {
            return $array;
        }

        if (static::exists($array, $key)) {
            return $array[$key];
        }

        foreach (explode('.', $key) as $segment) {
            if (Assert::array($array) && static::exists($array, $segment)) {
                $array = $array[$segment];
            } else {
                return $default;
            }
        }

        return $array;
    }
1316675
public function getValue($key) {
		if(isset($this->jsonArray[$key])) {
			return $this->jsonArray[$key];
		}

		return NULL;
	}
18642
public static function pluck(array $array, $key)
    {
        return array_map(
            function ($item) use ($key) {
                return is_object($item) ? $item->$key : $item[$key];
            },
            $array
        );
    }
877782
public static function indexOf(array $array, string $value, ?string $key = null)
    {
        foreach ($array as $index => $item) {
            if ($key !== null) {
                if (is_object($item)) {
                    $checkValue = isset($item->{$key}) ? $item->{$key} : null;
                } else {
                    $checkValue = isset($item[$key]) ? $item[$key] : null;
                }
            } else {
                $checkValue = $item;
            }
            if ($checkValue !== null && $checkValue === $value) {
                return $index;
            }
        }
        return -1;
    }
707867
public function getValueByPartialKey(array $array, string $searchingKey): ?string
    {
        foreach ($array as $key => $value) {
            if (false !== stripos($key, $searchingKey)) {
                return $value;
            }
        }

        return null;
    }
1074581
public static function get(array $array, $key = null, $default = null)
    {
        if ($key === null) {
            return $array;
        }

        if (isset($array[$key])) {
            return static::value($array[$key]);
        }

        foreach (explode('.', (string) $key) as $segment) {
            if (! array_key_exists($segment, $array)) {
                return static::value($default);
            }

            $array = $array[$segment];
        }

        return $array;
    }
942779
public static function keysExist ($array, $keys)
		{
			if (!is_array($array))
				return null;

			if (!is_array($keys))
				$keys = [ $keys ];

			foreach ($keys as $key)
				if (!array_key_exists($key, $array))
					return false;

			return true;
		}
699085
protected function arrayValue($key, $arrayKey, $value = null)
    {
        $array = $this[$key];
        $is = is_array($array);
        if (null !== $value) {
            if (!$is) {
                $array = array_key_exists($key, self::DEFAULTS)
                    ?self::DEFAULTS[$key]
                    :$this::DEFAULTS[$key];
            }
            $array[$arrayKey] = $value;
            $this[$key] = $array;
            return null;
        } else {
            return $is && isset($array[$arrayKey])
                ?$array[$arrayKey]
                :null;
        }
    }
1010123
protected function _get_array_value( $key ) {
		if ( ! isset( $this->types[ $key ] ) || 'array' !== $this->types[ $key ] ) {
			return null;
		}

		$default = array_key_exists( $key, $this->defaults ) ? $this->defaults[ $key ] : [];

		// @todo Could be taken a step further to array map strval?
		return (array) $this->store->get( $key, $default );
	}
518525
public static function GetLowest ($array, $keys) {
		foreach ((array) $keys as $key) {
			if (isset($array[$key]) || array_key_exists($key, $array)) {
				$array = $array[$key];
			} else {
				return null;
			}
		}
		return $array;
	}
1146043
public static function ensure_key_present($key, $array)
	{
		// ensure that the array we are checking is an array
		if (! is_array($array))
		{
			throw new ArraysException('Value of $array is not an array');
		}

		// if we are not checking an array of keys,
		// then just return array_key_exists check
		if (! is_array($key))
		{
			return array_key_exists($key, $array);
		}

		// gather the keys of the array
		$array_keys = array_keys($array);

		// itterate over the keys to check
		foreach ($key as $check_key)
		{
			// if the key does not exists
			if (! in_array($check_key, $array_keys))
			{
				// return false
				return false;
			}
		}

		// all keys exist
		return true;
	}
377895
public static function array_filter_values($array, $c = null)
    {
        if (isset($c['with'])) {

            $data = array();

            foreach ($array as $key => $value) {
                if (strpos($value, $c['with'])) {
                    $data[$key] = $value;
                }
            }

            return $data;
        } else {
            return array_filter($array);
        }
    }
1159773
public static function reduceToElementsWithKey($array, $key) {

        if ($array instanceof AssociativeArray) {
            $array = $array->toArray();
        }

        $targetArray = array();

        foreach ($array as $itemKey => $value) {

            if ($itemKey == $key) {
                $targetArray[$key] = $value;
            } else if (is_array($value) || $value instanceof AssociativeArray) {
                $subArray = ArrayUtils::reduceToElementsWithKey($value, $key);
                if (sizeof($subArray) > 0) {
                    $targetArray[$itemKey] = $subArray;
                }
            }

        }

        return $targetArray;

    }
682355
public static function pluck($array, $key)
    {
        return array_map(
            function ($v) use ($key) {
                return is_object($v) ? $v->$key : $v[$key];

            },
            $array
        );
    }