Skip to content

Instantly share code, notes, and snippets.

@skinnyjames
Last active June 14, 2018 01:01
Show Gist options
  • Save skinnyjames/9e0a9bd679caef33a6f2d513e151012b to your computer and use it in GitHub Desktop.
Save skinnyjames/9e0a9bd679caef33a6f2d513e151012b to your computer and use it in GitHub Desktop.
php aggregate
$new_array = array();
foreach($array as $vehicle_id) {
if(isset($new_array[$vechicle_id])) {
$new_array[$vehicle_id] += 1;
} else {
$new_array[$vehicle_id] = 1;
}
}
function sum($carry, $vehicle_id) {
$carry[$vehicle_id] +1;
return $carry
}
array_reduce($carry, $vechicle_array, array());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment