Created
June 22, 2012 19:57
-
-
Save troynt/2974806 to your computer and use it in GitHub Desktop.
closure in php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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')); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow. I had no idea PHP supports closures. Nice one.