Skip to content

Instantly share code, notes, and snippets.

View barbotkin's full-sized avatar

Roman Barbotkin barbotkin

View GitHub Profile
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active October 21, 2025 08:41
PHP : Groups an array by a given key
<?php
if (!function_exists('array_group_by')) {
/**
* Groups an array by a given key.
*
* Groups an array into arrays by a given key, or set of keys, shared between all array members.
*
* Based on {@author Jake Zatecky}'s {@link https://github.com/jakezatecky/array_group_by array_group_by()} function.
* This variant allows $key to be closures.