这个usort函数正在从我想要的方向返回数组.它返回一个数组("1","2","3").如何返回("3","2","1")?
usort($myArray, function($a, $b) {
return $a["comments"] - $b["comments"];
});
Run Code Online (Sandbox Code Playgroud)
Joe*_*Joe 25
只是反转参数?
usort($myArray, function($a, $b) {
return $b["comments"] - $a["comments"];
});
Run Code Online (Sandbox Code Playgroud)
usort($myArray, function($a, $b) {
return $b["comments"] - $a["comments"];
});
Run Code Online (Sandbox Code Playgroud)
只需将 A 更改为 B,将 B 更改为 A。