resort.php
2016-05-03 10:13
471 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> resort.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
echo "随机排序数组:<br>";
$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 "<br>倒序排列:<br>";
print_r($result);
//保持键值倒序排列
echo "<br>保持键值倒序排列:<br>";
$result_keyed = array_reverse($input, TRUE);
print_r($result_keyed);
?>
</body>
</html>
随机排序数组:
1 5 4 2 3
倒序排列:
Array ( [0] => hello [1] => 4 [2] => php )
保持键值倒序排列:
Array ( [2] => hello [1] => 4 [0] => php )
<html>
<head>
<title> resort.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
echo "随机排序数组:<br>";
$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 "<br>倒序排列:<br>";
print_r($result);
//保持键值倒序排列
echo "<br>保持键值倒序排列:<br>";
$result_keyed = array_reverse($input, TRUE);
print_r($result_keyed);
?>
</body>
</html>
随机排序数组:
1 5 4 2 3
倒序排列:
Array ( [0] => hello [1] => 4 [2] => php )
保持键值倒序排列:
Array ( [2] => hello [1] => 4 [0] => php )
相关文章推荐
- Yii2 输出xml格式数据的方法
- PHP array_reverse() 函数
- PHP 购物车 session(非框架)
- PHP语言 -- 文件上传
- array_reverse.php
- php面向对象值单例模式
- php调用接口
- PHP shuffle() 函数
- yii2 输出xml格式数据
- php使用ffmpeg获取视频信息并截图的实现方法
- all_sort.php
- yii2 输出xml格式数据
- smtp 邮件发送
- PHP rsort() 函数
- arsort.php
- 在PHP中调用接口
- ContentProvider的使用
- PHPExcel笔记, mpdf导出
- asort.php
- PHP实现的进度条效果详解