Home > Backend Development > PHP Tutorial > 关于数据排序的有关问题

关于数据排序的有关问题

WBOY
Release: 2016-06-13 10:42:21
Original
1038 people have browsed it

关于数据排序的问题
Array
(
  [175377] => 1
  [231940] => 2
  [192055] => 2
  [231723] => 1
  [199305] => 1
  [171165] => 4
  [220347] => 1
  [170288] => 10
  [231676] => 1
  [228438] => 2
  [215878] => 2
  [228851] => 1
  [194798] => 1
  [231220] => 1
  [192509] => 1
  [231913] => 2
  [231731] => 1
  [22747] => 1
  [171065] => 5
  [231922] => 1
  [230942] => 15
  [231919] => 1
  [171397] => 4
  [231916] => 1
  [209130] => 2
)

这样的数组应该如何排序,根据值的大小进行排序
[230942] => 15,[170288] => 10......

------解决方案--------------------
PHP的数组处理函数有很多,对于排序这样的基础问题,PHP的开发者肯定有注意到。
详见 ksort函数 对数组按照键名排序http://www.php.net/manual/zh/function.ksort.php
ksort($array, SORT_NUMERIC);
------解决方案--------------------
arsort($arr);
------解决方案--------------------
arsort($arr);

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template