Skip to content

Instantly share code, notes, and snippets.

View thobroni's full-sized avatar

Riza B.T. thobroni

View GitHub Profile
@mcaskill
mcaskill / Function.Array-Group-By.php
Last active May 23, 2025 10:43
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.