Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
根据内容订购PHP数组_Php_Arrays - Fatal编程技术网

根据内容订购PHP数组

根据内容订购PHP数组,php,arrays,Php,Arrays,我在PHP中有一个数组,如下所示: Array ( [2] => post4.post [3] => post7.post [4] => post5.post [5] => post3.post [6] => post6.post [7] => post1.post [8] => post2.post ) 我怎么能把它安排成这样 Array ( [0] => post7.post

我在PHP中有一个数组,如下所示:

Array
(
    [2] => post4.post
    [3] => post7.post
    [4] => post5.post
    [5] => post3.post
    [6] => post6.post
    [7] => post1.post
    [8] => post2.post
)
我怎么能把它安排成这样

Array
(
    [0] => post7.post
    [1] => post6.post
    [2] => post5.post
    [3] => post4.post
    [4] => post3.post
    [5] => post2.post
    [6] => post1.post
)
数组具有文件夹中包含的文件列表。在我的本地服务器上看起来像第二个示例,但在标准服务器上看起来像第一个示例

提前感谢:您正在寻找的D

PHP有很好的文档。我建议你看一看你要找的那篇文章(通过谷歌很容易找到)


PHP有很好的文档。我建议您看一看和这篇文章(可以通过Google;轻松找到)

您不想使用
rsort
,因为它会重新分配数组索引。而是使用

您不想使用
rsort
,因为它会重新分配数组索引。相反,使用rsort($array)将数组按相反/降序(从高到低)排序

为便于将来参考,请使用此页()确定最适合您需要的数组排序方法

rsort($array)
将按相反/降序(从高到低)对数组进行排序


为便于将来参考,请使用此页()确定最适合您需要的数组排序方法

从他的例子来看,他似乎想重新分配索引。我可以发誓,在我第一次阅读问题时,索引是保持不变的。从他的例子来看,他似乎想重新分配索引。我可以发誓,在我第一次阅读问题时,索引是保持不变的。啊,这比我强+1为Speedinessah赢了我+1.快速性