返回顶部

收藏

php通过sort()函数给数组排序

更多
$alpha = array ("x", "a", "f", "c");
sort( $alpha );

foreach ( $alpha as $var ) {
  print "$var<br />";
}

                                范例2
<?php
$my_array = array("a" => "Dog", "b" => "Cat", "c" => "Horse");

sort($my_array);
print_r($my_array);
?>

                                返回结果
Array
(
[0] => Cat
[1] => Dog
[2] => Horse
)

标签:数组排序,sort,php

收藏

0人收藏

支持

0

反对

0

发表评论