Returns the values from a single column of the input array, identified by the key.

@param  array  $array Array to pluck from
@param  string $key   Array key
@return array
192802
public static function pluck(array $array, string $key): array
	{
		$plucked = [];

		foreach($array as $value)
		{
			$plucked[] = is_object($value) ? $value->$key : $value[$key];
		}

		return $plucked;
	}
70213
private function getArray(Array_ $array)
    {
        $return = [];

        foreach ($array->items as $item) {
            if ($item->key === null) {
                $return[] = $this->getValue($item->value);
            } else {
                $return[$this->getValue($item->key)] = $this->getValue($item->value);
            }
        }

        return $return;
    }
1041063
public static function findByKey($array, $key, $value) {
        foreach ($array as $element)
            if (call_user_func(array($element, $key)) === $value)
                return $element;
        return null;
    }
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];
    }
11836
public static function pluck( $array, $value, $key = NULL )
    {
        $result = [ ];

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

            if ( is_null( $key ) )
            {
                $result[ ] = $itemValue;
            }
            else
            {
                $itemKey = is_object( $item ) ? $item->{$key} : $item[ $key ];

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

        return $result;
    }
693262
public static function keyedArray($array) {
        if(is_array($array)) {
            $string = '[ ';
            foreach($array as $key => $item) {
                if(!is_string($item)) {
                    $item = self::keyedArray($item);
                }
                $string .= $key . ' => ' . $item;
                if($item !== last($array)) {
                    $string .= ', ';
                }
            }
            $string .= ' ]';

            return $string;
        } else {
            if(is_object($array)) {
                return get_class($array);
            } else {
                if(is_null($array)) {
                    return 'Null';
                } else {
                    return 'Unknown';
                }
            }
        }
    }
35460
public static function get($array, $key, $default = null)
    {
        $key = static::normalizeKey($key);

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

        $keys = explode('.', $key);
        $currentElement = $array;

        foreach ($keys as $currentKey)
        {
            if (!is_array($currentElement) || !array_key_exists($currentKey, $currentElement))
            {
                return $default;
            }

            $currentElement = $currentElement[(string) $currentKey];
        }

        return $currentElement;
    }
1302295
public static function get(array $array, $key, $fallback = null)
    {
        $keys = explode('.', $key);
        foreach($keys as $key) {
            if(!isset($array[$key])) {
                return $fallback;
            }
            $array = $array[$key];
        }

        return $array;
    }
1340126
private function removeValue(&$array, $key)
    {
        $keys = explode('.', $key);

        while (count($keys) > 1) {
            $key = array_shift($keys);

            if ( ! isset($array[$key]) || ! is_array($array[$key])) {
                return;
            }

            $array =& $array[$key];
        }

        unset($array[array_shift($keys)]);
    }
582686
public static function arrayGet(array $array, $key, $default = null)
    {
        if (isset($array[$key])) {
            return $array[$key];
        }

        foreach (explode('.', $key) as $segment) {
            if (!is_array($array) || !array_key_exists($segment, $array)) {
                return $default;
            }

            $array = $array[$segment];
        }

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

            },
            $array
        );
    }
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;
	}
1164492
public function arrayCopy(array $array)
    {
        $copy = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $copy[ $key ] = $this->arrayCopy($value);
            } elseif (is_object($value)) {
                $copy[ $key ] = clone $value;
            } else {
                $copy[ $key ] = $value;
            }
        }

        return $copy;
    }
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;

    }
567293
public static function groupBy($array, string $key): array
    {
        if (! Assert::array($array)) {
            throw new InvalidArgumentException(
                '`Arr::groupBy` first parameter must be `array` or implements interface `ArrayAccess`'
            );
        }

        $grouped = [];

        foreach ($array as $row) {
            $k = $row[$key];
            $grouped[$k][] = $row;
            unset($k);
        }

        return $grouped;
    }
272631
function getKeysForDuplicates(array $array)
    {
        $duplicates = $newArray = [];

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

            if ( ! isset($newArray[ $value ])) {
                $newArray[ $value ] = $key;
                continue;
            }

            if (isset($duplicates[ $value ])) {
                $duplicates[ $value ][] = $key;
            } else {
                $duplicates[ $value ] = [
                    $newArray[ $value ],
                    $key
                ];
            }
        }

        return $duplicates;
    }
423995
public static function array_pick($array) {
    if (!is_array( $array )) {
      return $array;
    }
    $keys = array_slice(func_get_args(), 1);
    $keys = self::array_flatten($keys);
    $pick = array();
    foreach ( $keys as $key ) {
      if (!array_key_exists($key, $array)) {
        continue;
      }
      $pick[$key] = $array[$key];
    }
    return $pick;
  }