0
在数组上执行以下操作后,我得到此结果。不应该按'computer_name'排序吗?你会看到他们不是字母顺序。按值排序php数组未按预期工作
usort($test, function($a, $b) {
return $a['computer_name'] - $b['computer_name'];
});
echo "<pre>";
print_r($test);
echo "</pre>";
Array
(
[0] => Array
(
[computer_id] => 367
[account_id] => 1
[computer_name] => EXAMPLE_ONE
[last_username] => muah
[timestamp] => 2014-01-01 17:06:04
)
[1] => Array
(
[computer_id] => 366
[account_id] => 1
[computer_name] => TESTING
[last_username] =>
[timestamp] => 2013-12-06 20:02:14
)
[2] => Array
(
[computer_id] => 365
[account_id] => 1
[computer_name] => JOE-SCHMOE
[last_username] =>
[timestamp] => 2013-12-06 20:02:03
)
[3] => Array
(
[computer_id] => 18
[account_id] => 1
[computer_name] => SPORT-ONE
[last_username] =>
[timestamp] => 2012-10-16 03:31:22
)
[4] => Array
(
[computer_id] => 3
[account_id] => 1
[computer_name] => SPORT-TWO
[last_username] =>
[timestamp] => 2011-03-03 03:35:46
)
)
很好的发现......这个伎俩!我只是假设,但是当你像你这样解释的时候,这很有道理,为什么结果会发生。谢谢! – user756659