Skip to content

Instantly share code, notes, and snippets.

View SlashLife's full-sized avatar

Simon Stienen SlashLife

  • Berlin, Germany
View GitHub Profile
@SlashLife
SlashLife / gist:8982164
Last active August 29, 2015 13:56 — forked from blar/gist:8982098
<?php
function array_partition($array, $callback, $preserveKeys = false) {
$partitions = array();
foreach($array as $key => $value) {
$partition =& $partitions[call_user_func($callback, $value, $key)];
if (!isset($partition)) {
$partition = array();
}