Last active
August 31, 2020 04:23
-
-
Save rming/39c261633c03aa60b6ca5b4e7a6fdde7 to your computer and use it in GitHub Desktop.
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
<?php | |
$all=[ | |
['name'=>'zhangsan0','fenshu'=>'90'], | |
['name'=>'zhangsan1','fenshu'=>'89'], | |
['name'=>'zhangsan2','fenshu'=>'89'], | |
['name'=>'zhangsan3','fenshu'=>'70'], | |
['name'=>'zhangsan4','fenshu'=>'89'], | |
]; | |
usort($all, function ($a, $b) { | |
if ($a["fenshu"] !== $b["fenshu"]) return $a["fenshu"] <=> $b["fenshu"]; | |
return array_rand([-1, 1]) ? 1 : -1; | |
}); | |
var_dump($all); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment