您的位置:首页 > 编程语言 > PHP开发

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

2018-10-12 14:00 796 查看

<?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这么远的距离

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: