src/Utilities/Arrays.php
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;
    }
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;
    }
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 ; }
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
Returns all values of given key . It may be useful when you want to retrieve all values of one column .