douci4026 2011-07-15 12:37
浏览 19
已采纳

根据内容订购PHP数组

I have an array in PHP which looks like this:

Array
(
    [2] => post4.post
    [3] => post7.post
    [4] => post5.post
    [5] => post3.post
    [6] => post6.post
    [7] => post1.post
    [8] => post2.post
)

How could I arrange it so it could look like this?

Array
(
    [0] => post7.post
    [1] => post6.post
    [2] => post5.post
    [3] => post4.post
    [4] => post3.post
    [5] => post2.post
    [6] => post1.post
)

The array has a list of the files contained in a folder. In my local server looks like the second example but on a standard server looks like the first one.

Thanks in advance :D

  • 写回答

3条回答 默认 最新

  • dsn46282 2011-07-15 12:44
    关注

    rsort($array) will sort an array in reverse/descending order (from high to low).

    For future reference use this page (http://php.net/manual/en/array.sorting.php) to identify the most suited array sorting method for your needs.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 cad图纸,chx-3六轴码垛机器人
  • ¥15 移动摄像头专网需要解vlan
  • ¥20 access多表提取相同字段数据并合并
  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失