range.php
2016-05-03 10:16
495 查看
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> New Document </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
// 产生array(0, 1, 2, 3, 4, 5)
foreach (range(0, 5) as $number) {
echo $number;//012345
}
echo "<br>";
// array(0, 10, 20, 30, 40,),这里设置了step 参数
foreach (range(0, 40, 10) as $number) {
echo $number;//010203040
}
echo "<br>";
//产生字符数组
// array('a', 'b', 'c', 'd');
foreach (range('a', 'd') as $letter) {
echo $letter;//abcd
}
echo "<br>";
// array('c', 'b', 'a');第1 个参数大于第2 个参数
foreach (range('c', 'a') as $letter) {
echo $letter;//cba
}
?>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> range2.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
// 产生array(0, 1, 2, 3, 4, 5)
$number=range(0, 5);
var_dump($number);//012345
echo "<br>";
// array(0, 10, 20, 30, 40,),这里设置了step 参数
$number=range(0, 40, 10);
var_dump($number);//010203040
echo "<br>";
//产生字符数组
// array('a', 'b', 'c', 'd');
$letter=range('a', 'd');
var_dump($letter);//abcd
echo "<br>";
// array('c', 'b', 'a');第1 个参数大于第2 个参数
$letter=range('c', 'a');
var_dump($letter);//cba
?>
</body>
</html>
<html>
<head>
<title> New Document </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
// 产生array(0, 1, 2, 3, 4, 5)
foreach (range(0, 5) as $number) {
echo $number;//012345
}
echo "<br>";
// array(0, 10, 20, 30, 40,),这里设置了step 参数
foreach (range(0, 40, 10) as $number) {
echo $number;//010203040
}
echo "<br>";
//产生字符数组
// array('a', 'b', 'c', 'd');
foreach (range('a', 'd') as $letter) {
echo $letter;//abcd
}
echo "<br>";
// array('c', 'b', 'a');第1 个参数大于第2 个参数
foreach (range('c', 'a') as $letter) {
echo $letter;//cba
}
?>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title> range2.php </title>
<meta charset="UTF-8">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
</head>
<body>
<?php
// 产生array(0, 1, 2, 3, 4, 5)
$number=range(0, 5);
var_dump($number);//012345
echo "<br>";
// array(0, 10, 20, 30, 40,),这里设置了step 参数
$number=range(0, 40, 10);
var_dump($number);//010203040
echo "<br>";
//产生字符数组
// array('a', 'b', 'c', 'd');
$letter=range('a', 'd');
var_dump($letter);//abcd
echo "<br>";
// array('c', 'b', 'a');第1 个参数大于第2 个参数
$letter=range('c', 'a');
var_dump($letter);//cba
?>
</body>
</html>
array 0 => 0 1 => 1 2 => 2 3 => 3 4 => 4 5 => 5
array 0 => 0 1 => 10 2 => 20 3 => 30 4 => 40
array 0 => 'a' (length=1) 1 => 'b' (length=1) 2 => 'c' (length=1) 3 => 'd' (length=1)
array 0 => 'c' (length=1) 1 => 'b' (length=1) 2 => 'a' (length=1)
相关文章推荐
- PHP实现将颜色hex值转换成rgb的方法
- resort.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导出