Skip to content

Instantly share code, notes, and snippets.

@msg7086
Created April 3, 2015 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msg7086/01761d72e1d8c2cf12ae to your computer and use it in GitHub Desktop.
Save msg7086/01761d72e1d8c2cf12ae to your computer and use it in GitHub Desktop.
v2ex-181180
<?php
$hash = [];
foreach($rows as &$row) {
$key = $row['period'] << 32 | $row['price'];
if (isset($hash[$key]))
$hash[$key]['num'] += $row['num'];
else {
unset($row['id']);
$hash[$key] = $row;
}
}
print_r($hash);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment