resort.php
echo "随机排序数组:
";
$numbers = array(1,2,3,4,5);
shuffle($numbers);
foreach ($numbers as $number) {
echo "$number ";
}
$input = array("php", 4.0, "hello");
$result = array_reverse($input);
//倒序排列
echo "
倒序排列:
";
print_r($result);
//保持键值倒序排列
echo "
保持键值倒序排列:
";
$result_keyed = array_reverse($input, TRUE);
print_r($result_keyed);
?>
随机排序数组: 1 5 4 2 3 倒序排列: Array ( [0] => hello [1] => 4 [2] => php ) 保持键值倒序排列: Array ( [2] => hello [1] => 4 [0] => php )