src/Primitive/Support/Arr.php
public static function pluck($array, $value, $key = null)
    {
        $results = [];

        foreach ($array as $item)
        {
            if (isset($item[$value]) || isset($item->{$value}))
            {
                $itemValue = is_object($item) ? $item->{$value} : $item[$value];

                // If the key is "null", we will just append the value to the array and keep
                // looping. Otherwise we will key the array using the value of the key we
                // received from the developer. Then we'll return the final array form.
                if (is_null($key))
                {
                    $results[] = $itemValue;
                }
                else
                {
                    $itemKey = is_object($item) ? $item->{$key} : $item[$key];

                    $results[$itemKey] = $itemValue;
                }
            }
        }

        return $results;
    }
public static function pluck($array, $value, $key = null)
    {
        $results = [];

        foreach ($array as $item)
        {
            if (isset($item[$value]) || isset($item->{$value}))
            {
                $itemValue = is_object($item) ? $item->{$value} : $item[$value];

                // If the key is "null", we will just append the value to the array and keep
                // looping. Otherwise we will key the array using the value of the key we
                // received from the developer. Then we'll return the final array form.
                if (is_null($key))
                {
                    $results[] = $itemValue;
                }
                else
                {
                    $itemKey = is_object($item) ? $item->{$key} : $item[$key];

                    $results[$itemKey] = $itemValue;
                }
            }
        }

        return $results;
    }
Pluck an array of values from an array.

@param  array  $array
@param  string $value
@param  string $key

@return array