使用Arrayu multisort对数据重新排序

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用Arrayu multisort对数据重新排序相关的知识,希望对你有一定的参考价值。

This snippet allows an array or multiple arrays to be re-sorted using multiple key fields.
  1. $rows=$result->fetchAll(PDO::FETCH_ASSOC);
  2. $row2=$rows;
  3. $rSpec=array(); // create the key arrays
  4. $rDecl=array();
  5. $rDecl1=array();
  6. $rProp=array();
  7. foreach($rows as $r)
  8. {
  9. $rProp[]=$r['properties'];
  10. $rSpec[]=$r['specificity'];
  11. $rDecl[]=$r['declaration'];
  12. $rDecl1[]=$r['declaration'];
  13. }
  14. array_multisort($rSpec,SORT_NUMERIC,$rDecl,$rows);
  15. FunctionToWriteReport('CSS Rules by Specificty',$rows);
  16. array_multisort($rDecl1,$rProp,$row2);
  17. FunctionToWriteReport('Rules by Declaration',$rows);

以上是关于使用Arrayu multisort对数据重新排序的主要内容,如果未能解决你的问题,请参考以下文章