Skip to content

Instantly share code, notes, and snippets.

@troynt
Created June 22, 2012 19:57
Show Gist options
  • Save troynt/2974806 to your computer and use it in GitHub Desktop.
Save troynt/2974806 to your computer and use it in GitHub Desktop.
closure in php
<?php
function grouped_data_sorter($key) {
return function ($a, $b) use ($key) {
return strnatcmp($a[0]->$key, $b[0]->$key);
};
}
uasort($grouped_data, grouped_data_sorter('total_users'));
@wejn
Copy link

wejn commented Jun 23, 2012

Wow. I had no idea PHP supports closures. Nice one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment