页面导航: 首页网络编程PHP编程php技巧 → 正文内容 array_slice参数详解

php array_slice函数的使用以及参数详解

发布:dxy 字体:[增加 减小] 类型:转载
array array_slice ( array array, int offset [, int length]),根据 offset 和 length 参数所指定的 array 数组中的一段序列。offset 表示开始位置,length表示这段序列的长度.

<?php
/*
用手册上的例子
*/
$input = array ("a", "b", "c", "d", "e");
$output = array_slice ($input, 2); // returns "c", "d", and "e",
$output = array_slice ($input, 2, -1); // returns "c", "d"
$output = array_slice ($input, -2, 1); // returns "d"
$output = array_slice ($input, 0, 3); // returns "a", "b", and "c"
?>

重点说下length 为负.它表示取数组一直到距离数组末端length这么远的距离
Tags:php array_slice
浏览次数:载入中... 打印本文关闭本文返回首页

文章评论

共有 位脚本之家网友发表了评论我来说两句

同 类 文 章
最 近 更 新
热 点 排 行