简体   繁体   English

按索引对PHP中的数组进行排序

[英]Sort arrays in PHP by index

I have following array: 我有以下数组:

   $array[0]["nbr1"] = 5;

   $array[0]["nbr2"] = 7;

   $array[1]["nbr1"] = 1;

   $array[1]["nbr2"] = 6;

   $array[2]["nbr1"] = 2;

   $array[2]["nbr2"] = 3;

How can I sort this array first by "nbr1" descending and than by "nbr2" descending? 我如何才能先按“ nbr1”降序排序,然后按“ nbr2”降序排序此数组? I tried different things that were explained on the web but none of them worked for this scenario. 我尝试了在网络上解释过的不同方法,但是没有一种方法适用于这种情况。

Thx 谢谢

array_multisort($array[1], SORT_DESC, SORT_STRING);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM