Created
March 5, 2018 08:23
-
-
Save Enelar/692d2d7393a867e819e6e074399e0d82 to your computer and use it in GitHub Desktop.
Cleanest user compare function
This file contains 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
function ucmp($a, $b) | |
{ | |
$diff = $a - $b; | |
return ($diff > 0) - ($diff < 0); | |
} | |
usort([7,8,-1], "ucmp"); | |
function you_get_the_idea($a, $b) | |
{ | |
$diff = $a['price'] - $b['price']; | |
return ($diff > 0) - ($diff < 0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment