Blogger Information
Blog 91
fans 0
comment 0
visits 203404
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP 将一位数组进行倒序排列
何澤小生的博客
Original
2803 people have browsed it

php按照原数组的顺序倒序排列

方法一:

 array_reverse() 返回单元顺序相反的数组

$array = [1,2,3,4,5,6,7,8,9];
$arr = array_reverse($array);
dump($arr);


方法二:

for 循环处理

$array = [1,2,3,4,5,6,7,8,9];
$arr = [];
// for 循环处理
for($i=count($array)-1; $i>=0; $i--)
{
     $arr[] = $array[$i];
}

dump($arr);


01——result.png





发现问题,解决问题是一个很开心的事情哈。

有什么疑问可以留言咨询哈~~~




转载请注明出处~~~~


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post