欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

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

程序员文章站 2022-05-24 17:06:50
...
复制代码 代码如下:

/*
用手册上的例子
*/
$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这么远的距离
相关标签: php,array_slice